Rajat
Rajat

Reputation: 61

Regular Expression matching every character except <,>,",/,\

I am writing a JavaScript regular expression to match a string containing any possible character (including spaces) except any of the following five special characters <,>,",/,\. I have tried using ^ inside [] which skips matching the characters inside [] such as /[^<>""\\/]/ but this doesn't seem to work as expected

Upvotes: 0

Views: 63

Answers (1)

Kirill Bulygin
Kirill Bulygin

Reputation: 3826

You almost did it, use this: /^[^<>"\/\\]*$/.

Demo: https://regex101.com/r/s7DEKm/1.

Upvotes: 3

Related Questions