Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Reading Reg Exp

by JavaFan (Canon)
on Aug 11, 2010 at 10:45 UTC ( [id://854315]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Reading Reg Exp
in thread Reading Reg Exp

But even ignoring locale or encoding, it's still not listing 80% of the characters the class can match. That's like saying [a-z] matches all the vowels.

Replies are listed 'Best First'.
Re^5: Reading Reg Exp
by kejohm (Hermit) on Aug 12, 2010 at 07:34 UTC

    According to the perlrecharclass manpage:

    \s matches any single character that is considered whitespace. In the ASCII range, \s matches the horizontal tab (\t), the new line (\n), the form feed (\f), the carriage return (\r), and the space.

    It also says:

    Without a locale or EBCDIC code page, \s matches the five characters mentioned in the beginning of this paragraph.

    Update: Link fixed.

      Both cases are talking about matching ASCII characters. The first mentioning ASCII, the second when it's discussing non-UTF8 matching.

      But the explain of the regex cannot know whether UTF-8 matching is in effect or not, as that will depend on the encoding of the subject string.

        But the explain of the regex cannot know whether UTF-8 matching is in effect or not, as that will depend on the encoding of the subject string

        Good point. Especially if you pass a pre-compiled regex instead of a string. I think for what the module is trying to do, the simplest usages would suffice for most cases.

Re^5: Reading Reg Exp
by choroba (Cardinal) on Aug 11, 2010 at 10:49 UTC
    Consonants, rather :)
      Out of 26 characters, 5 are vowels (ignoring the fact 'y' and Welsh 'w' sometimes play the role of vowel). Which is about 20% of the characters 'a' to 'z'. \s matches 25 characters, but the explain lists 5.

      So, I did mean vowels where I wrote vowels.

        OK, you're right.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found