C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Tips » Web Development »

Commonly used reguler expressions


Posted Date: 05 Nov 2009    Resource Type: Tips    Category: Web Development
Author: PrajeeshMember Level: Gold    
Rating: 1 out of 5Points: 3



In most of the projects you may be used various reguler expressions frequently. Here is the list of some commonly used reguler expressions for validating your forms.

E-mail:


^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$


Example:yourname@provider.com

URL:


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


Example: http://www.dotnetspider.com

US Social Security Number:


^\d{3}-\d{2}-\d{4}$


Example: 111-11-1111

Phone number(Validates US Phone number):


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


Examples:
(234) 656-0123
234-444-0123
325 444 0123
1-325-444-0123

Zip Code(Validates US Zip code):


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


Example:
23456

Currency(Non Negative):


^\d+(\.\d\d)?$


Example:
23.00

Currency(+ve or -ve):


^(-)?\d+(\.\d\d)?$


Example:
23.00
-24.00

Non Negative Integer:


^\d+$


Examples:
123
456

Hope this helps you.

For more details, visit http://msdn.microsoft.com/en-us/library/ms972966.aspx



Responses

Author: Abhay    05 Nov 2009Member Level: Diamond   Points : 1
Hi prajeesh,
can u add one example for each?

It will be better.
It is looking odd also.



Author: Prajeesh    05 Nov 2009Member Level: Gold   Points : 0
Hi Abi,

I added examples for each, also formatted a bit.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Regulerexpressions  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Changing Meta tags dynamically
Previous Resource: Refresh your ASP.net page automatically
Return to Discussion Resource Index
Post New Resource
Category: Web Development


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use