regex - Unexpected working of Negated Shorthand Character Classes -


the regular expression

/[\d\s]/ 

should match characters not digit or not whitespace

but when test expression in regexpal

it starts matching character that's digit, whitespace

what doing wrong ?

\d = characters except digits, \s = characters except whitespaces

[\d\s] = union (set theory) of above character groups = characters.

why? because \d contains \s , \s contains \d.

if want match characters not dights nor whitespaces can use [^\d\s].


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -