Reputation: 8548
When I use \W
in Regex
, it will get all special character, but I wan not get Space.
How to can I get all special character using Regex, where it is not Space, in javascript
?
Upvotes: 0
Views: 35
Reputation: 1329
You could simply use [^\s\w]
which will return all characters that are not space nor letters
Upvotes: 1
Reputation: 785088
You can use negated character class instead:
[^\w\s]
This will match a character that is not a word character and not a white-space.
Upvotes: 1