Subscribe to Subscribers
Talk to Webmaster Tony John


Resources » Technical Tips » General

Using Regular expressions..


Posted Date:     Category: General    
Author: Member Level: Gold    Points: 6


Regular expressions are used to validate the input values, to check it is in correct format as per our requirement. For that we can use the validation controls with expressions. Just drag and drop the regular expression validator and set the target control ID to the textbox to validate. Then set the regular expression.



 


Regular expressions are used to validate the input values, to check it is in correct format as per our requirement. For that we can use the validation controls with expressions as below.

Name
 ^[a-zA-Z''-'\s]{1,40}$


Social
Security
Number
^\d{3}-\d{2}-\d{4}$


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


E-mail
    ^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\                            {\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$




URL
          
^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)* (\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$


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



Password
   (?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$



Non-
negative
integer
^\d+$





Did you like this resource? Share it with your friends and show your love!


Responses to "Using Regular expressions.."
Author: sandy    01 Jun 2012Member Level: Gold   Points : 0
Hi

Good tips for regular expression validators



Author: chidambaram    01 Jun 2012Member Level: Gold   Points : 0
Thank you..


Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Certifications for many languages
    Previous Resource: Know more about Code Refactoring
    Return to Resources
    Post New Resource
    Category: General


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    All regular expressions  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.