Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the regular expression for "No quotes in a string"?

Tags:

regex

asp.net

I am trying to write a regular expression that doesn't allow single or double quotes in a string (could be single line or multiline string). Based on my last question, I wrote like this ^(?:(?!"|').)*$, but it is not working. Really appreciate if anybody could help me out here.

like image 450
GLP Avatar asked Oct 13 '11 03:10

GLP


1 Answers

Just use a character class that excludes quotes:

^[^'"]*$

(Within the [] character class specifier, the ^ prefix inverts the specification, so [^'"] means any character that isn't a ' or ".)

like image 158
Amber Avatar answered Oct 13 '22 01:10

Amber