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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -