Regular expression for asp.net

I need some help in regular expression. I am validating the textbox text when updating the records. When i click the update button, the first 5 letters should be equal to CM000 or cm000. How to validate this using regular expression in asp.net. does anyone know validationexpression for this. Let me know .

Thanks

Answers


You don't need a regex - do this instead:

bool isValid 
    = textBox.Text.StartsWith("CM000", StringComparison.OrdinalIgnoreCase);

If you must use a regex (like for a validation control) then use something like this:

<asp:RegularExpressionValidator 
    runat="server" 
    id="someId" 
    controltovalidate="textBox"
    validationexpression="^(?:CM|cm)000"
    errormessage="Invalid input" />

Need Your Help

pagination using php and mysql without limit clause

php mysql pagination limit

I have to create a blog for a site and I need a pagination script to display the blog posts like wordpress.

Uploading Images to Server android

android http-post image-uploading

I wanted to know which is the best way to upload image to server without loosing its quality.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.