user2395176
user2395176

Reputation: 315

Regex for checking some special characters

I need a regex to check if the input contain following characters

\/:*?:"<>|

The input can allow all the keyboard keys except the above mentioned.

Upvotes: 0

Views: 47

Answers (1)

hwnd
hwnd

Reputation: 70750

You can use a negated character class [^ ] here.

^[^\\/*?:"<>|]*$

Regular expression:

^                  # the beginning of the string
 [^/*?:\"<>|]*     # any character except: '\', '/', '*', '?', ':', '"', '<', '>', '|' (0 or more times)
$                  # before an optional \n, and the end of the string

Upvotes: 1

Related Questions