Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Extended Regular Expressions

by azatoth (Curate)
on Aug 16, 2001 at 17:40 UTC ( #105363=note: print w/ replies, xml ) Need Help??


in reply to Extended Regular Expressions

Read up on Character Classes & Negated Character Classes, or speak to japhy about them if he's around.

Also, take a look at Death to Dot Star!.

Feel free to ask in the ChatterBox if you are still having problems after you've done the required reading.

Azatoth a.k.a Captain Whiplash

Make Your Die Messages Full of Wisdom!
Get YOUR PerlMonks Stagename here!
Want to speak like a Londoner?


Comment on Re: Extended Regular Expressions
Re: Re: Extended Regular Expressions
by jroberts (Acolyte) on Aug 16, 2001 at 18:02 UTC
    Thanks, i got this to work as expected using "negated" character classes. My original question still remains as a puzzle. why aren't the results (aka. the values of $&) of the two pattern matches different by the single character 'j' (taken from "joe")? it seems they should be. the zero-width lookahead doesn't seem to be "zero-width" at all. Regards, jroberts

      Ok, the problem with [^\z] can be easily seen when you use warnings - which is a good idea in general. Perl complains then about an unidentified escape sequence in the character class. This means that \z is not the end of the string in a character class!! All metacharacters loose their special meaning in a character class.

      So [^\z] is equivalent to [^z] which is a single character that is not a 'z'. Looking at your original regex print $& if /^<a href.*>(?=[^\z])/x;
      Consequently the .* in your regex eats up everything till the last '>' and checks if the next character is not a z. Which is true, as it is a newline. Ergo, match found, mystery solved :)

      -- Hofmator

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-10-24 21:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (137 votes), past polls