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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -