Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
We don't bite newbies here... much
 
PerlMonks  

Re: Backreferences

by snax (Hermit)
on Jul 23, 2003 at 11:07 UTC ( [id://277193]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 11: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|$)/;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277193]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.