Regex not to escape just < > =?

Asked

Viewed 80 times

3

I currently have the following regex:

"/([^\w\.\,]+\s*)/"

It escapes, letters, numbers, commas and dots followed or not by space. How do I let it escape everything except the characters: < > = !

  • You want to marry only the characters < > = ! that?

  • Yes, only those characters, whether or not followed by space

1 answer

5


  • It worked, so too (which I did according to your previous answer) [(<|>|=|!)].

  • 3

    Parentheses and | inside brackets are taken literally, not as special syntax. This regex also does not accept (, | nor ). If you want to deny a character set, simply do /[^<>=!]/g. P.S. And the comment of @Leonardovilarinho accepts (, | and ) when you shouldn’t accept.

  • 1

    @mgibsonbr, you have prayer, had not attacked me to it. I will edit the answer with your suggestion. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.