9

Does any one know how to include double quote in regular expression.I wrote this regex but unable to include the double quote

<asp:RegularExpressionValidator ID="KeywordsRegex" runat="server" 
 ValidationExpression="^[+\-\!\(\)\:\^\[\]\{\}\~\*\?\&&\||].*$" 
 ControlToValidate="Keywords" ErrorMessage="Search keyword is not valid." 
 Text="*"></asp:RegularExpressionValidator> 
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
Asp.Net Dev
  • 135
  • 1
  • 3
  • 10
  • this solve it definitelly \22\42. http://stackoverflow.com/questions/1616190/quotes-inside-validationexpression-for-regularexpressionvalidator – Martin Matuska Jan 19 '15 at 19:28

4 Answers4

13

Try putting a backslash (\) followed by &quot;. That would be proper XML.

Oscar Broman
  • 1,109
  • 8
  • 19
1

have you tried escaping the double quote with a backslash?

Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
0

you may need to double escape, eg \\\"

scibuff
  • 13,377
  • 2
  • 27
  • 30
0

Try to escape it : Replace each " by \"

Guillaume USE
  • 436
  • 1
  • 4
  • 6