in reply to Backreferences

You want:
$line =~ /\shref=(["'])?([^\s\>]+)\1/;
-- you're grabbing the first matched quote character in the parentheses because, as noted above, you can't use the backreference the way you wanted. Once you have the opening quote, though, you can use it as shown in this regex to terminate your match.

(edited for clarity)

Replies are listed 'Best First'.
Re: Re: Backreferences
by Thelonius (Priest) on Jul 23, 2003 at 15:38 UTC
    You want:
    $line =~ /\shref=(["'])?([^\s\>]+)\1/;
    No, that's not quite right, because he wants to find hrefs that are (probably) mistakes, stopping at the first space or > character. Something like this is closer, although I'm sure the regex gurus can improve on it:
    $line =~ /\shref=(["'])?(.+?)(?=[\s>]|\1|$)/;