Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: ^\s not equal \S?

by Abigail-II (Bishop)
on Dec 04, 2003 at 09:54 UTC ( #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).


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. :)


      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.


Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2023-12-02 19:00 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (18 votes). Check out past polls.