Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Re: This looks like someone sneezed and hit the keyboard

by bunnyman (Hermit)
on Feb 03, 2004 at 16:33 UTC ( [id://326228]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: This looks like someone sneezed and hit the keyboard
in thread This looks like someone sneezed and hit the keyboard

No, everything in the regex must match, not just the first part of it, and the part in the middle with the (one|two|three) must match too.

The thing that you must remember is that regexes can backtrack -- if they get to the end of the string without having matched yet, they can go back a few letters and try again.

So the .* part will first try to match the entire string, because it is greedy. Then the middle part (one|two|three) must match, but there is nothing left in the string, and we must backtrack and try again. First we try going one letter back, then two, and eventually we either find the match or we backtrack all the way to the start and then there is no match.

  • Comment on Re: Re: Re: This looks like someone sneezed and hit the keyboard

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found