programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, June 25, 2014

How to use regular expression

How to use regular expression in

Regular expression is a pattern matching standard (way ) for string parsing and replacement. That used on a wide range of platforms and programming (Application development) environments. Some time we can say that Regular expression is a way of Clint side validation. The short form of Regular Expression is regales. This reg form regular and exes from expressions.

Regular expression in

•Use regular expressions for constrain input, apply format rules, and check lengths of string or input data.
•Use the ASP.NET Regular Expression Validator control for constrain and validate input with given condition.
•Use the Regular Expression (regexes) class to constrain and validate client input data.
•knowledge common regular expressions that can be used to constrain input data in programming.

 Example of regular expressions can be used to parse dates, url(universal resource locator) and email addresses, file type, log files, text, String, Numeric values, configuration files, command line switches or programming scripts.

Basically there are fallowing steps To validate a server control's input using a Regular Expression Validator are:-

1 .Add a Regular Expression Validator control in page.
2 .Set Validate Control (by using control ID).
3. Set the Validation Expression property with regular expression (validation conditions).
4. Set the Error Message property, for define the Error message to display if the validation fails.

Regular expression for Enter number only in Textbox :

<asp:TextBox ID="Txtbox" runat="server"

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
Control To Validate="Txtbox" ErrorMessage="You must enter a phone number in the form of (999) 999-9999."
ValidationExpression="^[\d\s\(\)\-]+$" ValidationGroup="ch"/>

Regular expression  for URL validation 



Regular expression  for ZIP code validation

^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$

Regular expression  for Password Validation 


Regular expression  for Non- negative integer validation


Regular expression  for Currency (non- negative) validation


Regular expression  for Currency (positive or negative) validation


Regular expression  for Phone Number Validation :

^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$

Regular expression  for Email Validation : 


Regular expression  for Image format validation 

<asp:RegularExpressionValidator ID="revImage" ControlToValidate="uplImage"
ValidationExpression="^.*\\.((j|J)(p|P)(e|E)?(g|G)|(g|G)(i|I)(f|F))$" Text=" ! Invalid image type" runat="server" />

Related Questions :

  1. building a multiple email regular expression for a regular expression validator on with c#   Programming
  2. regular expression validation in
  3. Prevent Range Validator to show error message with regular expression validator in Parogramming
  4. in Text with RegEx Validator not working
  5. Regex Help needed with field validation in
  6. Regex for required field in Asp?
  7. Validate date field in using validator control in Prograaming

Other Impotent Post: