[Solved] JavaScript: what is the regex to trim other than A-Z a-z 0-9 and symbols?


You could use a negated class like:

[^A-Za-z0-9\s]

Btw, you also can shorten it to:

[^A-Za-z\d\s]

And.. if you don’t mind to preserve underscores your could use:

[^\w\s]

The idea of the negated class is to not match the characters in it. For this regex:

[^A-Za-z0-9\s]

it means:

^       ---> not match the following
A-Za-z  ---> letters from a-z insensitive
\d      ---> digits from 0 to 9
\s      ---> spaces, tabs, etc (whitespaces)

Working demo

enter image description here

0

solved JavaScript: what is the regex to trim other than A-Z a-z 0-9 and symbols?