Exclude caracters from \W

3672 views regex

I want to know if it's possible to exclude some special characters from \W in RegExp.

For example, I want to allow sentences with ? or , or ! or ç, space and so on... If I use \W_ it'll match all special characters! There's a way to exclude ?, ,, !, ç etc.?

You know, exactly like it's possible to add _ to \W...

Is there's a simple way to exclude characters from it?

answered question

1 Answer


You can just use [^\w ?!ç], etc.

posted this

Have an answer?


Please login first before posting an answer.