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

Re: regexp question

by JavaFan (Canon)
on Oct 28, 2011 at 08:36 UTC ( [id://934338]=note: print w/replies, xml ) Need Help??


in reply to regexp question

Because having a character inside the character class that matches every but a newline doesn't make much sense. What would be the advantage of using /[.]/ over /./ if a dot meant the same thing inside a character class as outside it?

Replies are listed 'Best First'.
Re^2: regexp question
by ramprasad27 (Sexton) on Oct 28, 2011 at 08:58 UTC
    I would ask you the same question whats advantage in this case /[\d\s]/; meaning doesnt change outside of cc
      Of course it's different.
      [\d\s] # matches a single char - digit or whitespace \d\s # matches two chars - a digit then whitespace
      Because one can use \d and \s to build larger character classes. A dot already matches everything but a single character.

      What's the point of having such a character inside a character class? All you can do is build 4 different character classes: /[.]/, /[.\n]/, /[^.]/, /[^.\n]/. But they can all be written in a simple, different way: /./, /(?s:.)/, /\n/, and /(*FAIL)/

      So, once again, what would be the advantage of having dot inside a character class mean the same thing as outside of it?

        A dot already matches everything but a single character.

        Err... are you sure you meant to say that?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found