Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: ^\s not equal \S?

by Abigail-II (Bishop)
on Dec 04, 2003 at 09:54 UTC ( [id://312158] : note . print w/replies, xml ) Need Help??


in reply to ^\s not equal \S?

$ perl -Dr -ce '/[\S*\W*]/' Compiling REx `[\S*\W*]' size 13 Got 108 bytes for offset annotations. first at 1 1: ANYOF[\0-\377!utf8::IsSpacePerl !utf8::IsWord](13) 13: END(0) stclass `ANYOF[\0-\377!utf8::IsSpacePerl !utf8::IsWord]' minlen 1 Offsets: [13] 1[8] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 9[ +0] Omitting $` $& $' support. EXECUTING... -e syntax OK Freeing REx: `"[\\S*\\W*]"'

Now, pay attention to the 'ANYOF' part. It includes all the ASCII and LATIN-1 characters (it also includes lots of Unicode characters, but that's not important right now).

Abigail

Replies are listed 'Best First'.
Re: Re: ^\s not equal \S?
by davido (Cardinal) on Dec 04, 2003 at 09:58 UTC
    Now that's a neat trick. After getting up off the floor following fainting at the very sight of it, I'll have to read perlrun again to understand how you did it. It's high time I dig into perldebug too, I see.

    Thanks for the motivation / lesson. :)


    Dave

      I find '-Dr' far more useful than 'YAPE::Regex::Explain'. The latter just parrots back what it was given, but then in English. '-Dr' shows how perl compiles it. As shown in the thread 'YAPE::Regex::Explain' doesn't notice the overlap between \S and \W, not even that '*' is mentioned twice. '-Dr' shows what's really going on, although the output is sometimes hard to grog.

      And '-Dr' really shines at runtime, showing how Perl actually matches a regexp.

      Abigail