Regex Help

Discussion in 'Programming' started by QuackWare, Feb 10, 2010.

  1. #1
    Hi, I am looking for the Regex expression that will strip the link out of this href tag based on the id that is given. The language does not really matter since (I think) regex is the same for all languages.

    
    <a href="http://www.example.com" id="example">
    Code (markup):
    So I only want to get the link "http://www.example.com" if the id of the href is "example"

    Thanks in advance.
     
    QuackWare, Feb 10, 2010 IP
  2. spiderman3

    spiderman3 Peon

    Messages:
    177
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Regex = "[href=]\"\""

    use this technique.
     
    spiderman3, Feb 12, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    <?php
    
    $href = <<<EOF
    <a href="http://www.example.com" id="example">
    EOF;
    
    preg_match("/<a href=\"(.*)\" id=\"example\">/", $href, $strip);
    
    echo $strip[1];
    
    ?>
    PHP:
     
    danx10, Feb 16, 2010 IP