What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 25000 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > Syntax to use Regex for validation ...
Madhu.b.rokkam

Syntax to use Regex for validation

 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:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 7:39:32 AM