Code Snippet posted by:
Madhu.b.rokkam | Posted on: 2/27/2011 | Category:
C# Codes | Views: 1085 | Status:
[Member] [MVP] |
Points: 40
|
Alert Moderator
Regex regex = new Regex(YourSearchPattern);
bool isMatch = regex.IsMatch(YourSourceString);
Console.WriteLine("SourceString : {0} isMatch: {1}", YourSourceString, Convert.ToString(isMatch));
example
string YourSourceString = "Madhu";
string YourSearchPattern = "[a-z]{5}";
Regex regex = new Regex(YourSearchPattern);
bool isMatch = regex.IsMatch(YourSourceString);
Console.WriteLine("Source String: {0} isMatch: {1}", YourSourceString, Convert.ToString(isMatch));
output
Source String: Madhu isMatch: False
Thanks and Regards
Madhu
Found interesting? Add this to: