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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Aug 24, 2011, 11:52 AM
VulpesPosted Aug 24, 2011, 10:24 AM
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