Of course it's different.
[\d\s] # matches a single char - digit or whitespace
\d\s # matches two chars - a digit then whitespace
| [reply] [d/l] |
[\d]
\d
| [reply] [d/l] |
| [reply] |
You're missing the whole point here. Square brackets are a character class. If I try to match on [a-z0-9], I'm specifying one character that falls in the class of characters from a-z and 0-9. That is, I'm trying to match one character that could be any of those in the class.
But if I try to match on [.], I'm specifying one character that falls in the class of characters that are a period. In other words, [a-z] could match 'a', or 'b', or 'c', etc., but [.] can only ever match '.'. So [.] is exactly equal to '.' Thus it's a useless use of a character class.
To use another example of yours, [\d\s] will match one character that is either a digit or a space character. It could match 9, or 8, or ' '. \d and \s retain their "magic" even in a character class. [\d] = \d = [0-9]
The lesson here is don't use single-character classes.
--marmot
| [reply] [d/l] [select] |
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? | [reply] [d/l] [select] |
| [reply] |
Yes. Care to point out another character beside a newline that isn't matched by a dot?
| [reply] |