Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Link reg expression

by CukiMnstr (Deacon)
on Jun 19, 2003 at 18:09 UTC ( #267296=note: print w/replies, xml ) Need Help??


in reply to Link reg expression

it fetchs other end quotes because you are asking it to with .*. If you change your code to:
if ( $line =~ m/(https?:[^"]+")/ )
it should work. Also, you could try the non-greedy form:
if ( $line =~ m/(https?:.+?")/ )
check perlre for more on the non-greedy quantifiers, and read this post by Ovid on the dangers of .*.

hope this helps,

update: you should be using a module specifically designed to deal with links in html documents for this, anyway.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://267296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-02-19 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (81 votes). Check out past polls.

    Notices?