i am using following regular expression in asp.net
"^[a-zA-Z0-9-_/.#$%^*()}{:;+=|!,?~@&<>' ]*$"
please reply the answer to my question.
Thank you,
G. Nagaraju
"^[a-zA-Z0-9-_/.#$%^*()}{:;+=|!,?~@&<>' ]*$"
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Aug 24, 2011, 6:24 AM EDT
1. Single quotes or double quotes or both
2. Single quotes or double quotes but not both.
I'd need to think about the second one but the first one would be just a matter of doubling the double quotes and using a verbatim string:
string text = @"'"""; // includes single and double quotes
string r = @"^[a-zA-Z0-9-_/.#$%^*()}{:;+=|!,?~@&<>'"" ]*$"; // allow for either or both
bool b = Regex.IsMatch(text, r); // true
VulpesRank #55 · 29.2K reputationPosted Aug 24, 2011, 7:52 AM EDT