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 » Articles » ASP.NET/Web Applications »

Regular Expressions for Beginners


Posted Date: 01 Jun 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Sridhar Rama SubramanianMember Level: Bronze    
Rating: 1 out of 5Points: 4





Start and End of Line

You can easily match strings that start or end with certain characters.

The ^ character matches the start of the string.
^hello matches hello there, hello sam, hellostop.

To match the end of the string, use the $ character
ere$ matches Where, and There.

Character Classes

[aeiou]
Matches Hey, and Hi, but not Zzz.
Atleast One character from the set
[^aeiou]
Matches Zzz, but not Hey or Hi.
No character from the set
^[aeiou]
String should start with an Vowel
[0-9] Numbers between 0 to 9

[0-9] [0-9] Any two digit Numbers

[a-zA-Z0-9_] or \w Matches character found in word

([^a-zA-Z0-9_]) or \W Anything other than a word character

\s For any whitespace character

\S For any non whitespace character

Some examples:

Zip code: ^[0-9]{5}
Ex: 97213, 01267

Zip Code ^[0-9]{5}-[0-9]{4} or ^\d{5}-\d{4}$
Ex:97213-4834

^d{1,3}$ matches 1,15,987

^d{1, }$ One or More digits

^[+-]{0,1} \d{0,}$ matches 123, +123, -123

(?i:[aeiou]) matches hello, and HELLO, but not Zzzz.

Date: ^\d{1,2}/|-\d{1,2}/|-d{4} matches 12/04/2004 or 12-04-2004




Responses

Author: precee    07 Jun 2004Member Level: Bronze   Points : 0
This information very usefull for programming,Give more examples please.


Author: Rakesh Chander Sharma    15 Jun 2004Member Level: Silver   Points : 0
Very Useful Information . Keep It up.

Rakesh


Author: Resmi R    18 Jun 2004Member Level: Bronze   Points : 0
It was very good.Thanx a lot..I was in need of it.


Author: samuel charles finny    10 Aug 2004Member Level: Bronze   Points : 0
if i want to check out whether a number is valid or not what expression v must give. for ex. we should not enter
+-9,.+9,/9., and a lot like this . we must calculate in all the ways possible by permutations and combinations. also it must allow expressions like +0.9,-9.0,....
so could anyone clarify me
thanks ...


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

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: Building a 3-Tier ASP.NET Application using Notepad
Previous Resource: Two ways sorting in a datagrid
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use