I am using parsley for javascript validation. My current regex pattern is
data-parsley-pattern="/^[0-9a-zA-Z\!\@\#\$\%\^\&\*\(\)\-\_\+\?\'\.\,\/\\r\n ]+$/"
How to add double quote in my pattern. I have added \" to pattern
data-parsley-pattern="/^[0-9a-zA-Z\!\@\#\$\%\^\&\*\(\)\-\_\+\?\'\"\.\,\/\\r\n ]+$/"
But it is not working.
Note that you overescaped the pattern, almost all the chars you escaped are not special in a character class.
Next, you may shorten the code if you use a string pattern. See Parseley docs:
That means you do not need
^and$if you define the pattern without regex delimiters,/.As for the quotation marks, you may use a common
\xXXnotation.You may use
or
where
\x27is'and\x22is".Note that
-at the end of the character class is a safe placement for a literal hyphen where you do not have to escape it.