Lai32290
Lai32290

Reputation: 8548

How to can I get all special character, where is not SPACE, using Regex?

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

Answers (2)

AdminXVII
AdminXVII

Reputation: 1329

You could simply use [^\s\w] which will return all characters that are not space nor letters

Regex101

Upvotes: 1

anubhava
anubhava

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.

RegEx Demo

Upvotes: 1

Related Questions