5,427,303 members and growing! (17,086 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Beginner License: The GNU General Public License (GPL)

Regular Expressions which are needed in daily coding...

By JustChiragPatel

Regular Expressions for all purpose..
Windows, .NET 1.1, .NET 2.0, .NET, ASP.NET, Visual Studio, VS.NET2002, VS.NET2003, VS2005, Dev

Posted: 21 Mar 2007
Updated: 21 Mar 2007
Views: 13,082
Bookmarked: 10 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
20 votes for this Article.
Popularity: 2.50 Rating: 1.92 out of 5
13 votes, 65.0%
1
1 vote, 5.0%
2
0 votes, 0.0%
3
0 votes, 0.0%
4
6 votes, 30.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Guys , we all know that regular expressions are very useful for checking any kind of patterns.

Background

So we have to know how to write regular expressions for our patterns. But don't worry here i will provide some but very useful regular expressions which will be useful for our coding.

Using the code

just copy and paste Regular Expression from here to your code.
//

// this are the regular expressions for all purposes...

//For checking opening and closing tab of specific HTML tags..

"regex"><TAG\b[^>]*>(.*?)</TAG>
//for any HTML tags starting and ending..

"regex"><([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>
//For deleting white spaces from text...

"regex">^[ \t]+|[ \t]+$
//For Checking IP address between 0..255...

"regex">\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\."regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9]
"regex">[0-9]?)\."regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\."regex">
"regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"regex">"regex">"regex"> 
//For floating point numbers with sign...

"regex">[-+]?[0-9]*\.?[0-9]+
//for floating point numbers with exponents...

"regex">[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?"regex"> 
//For email validation...

"regex">^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$
"regex">"regex">"regex">"regex">"regex">"regex">//or you can try for .Museum and etc..

"regex">"regex">"regex">"regex">"regex">"regex">^[A-Z0-9._%-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$
"regex">"regex">"regex">"regex">"regex">"regex">
//Date format for yyyy-mm-dd betwwen 1900-01-01 and 2099-12-31

"regex">(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])
"regex">//Date format for mm/dd/yyyy betwwen 1900-01-01 and 2099-12-31 

"regex">(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d"regex"> "regex"> 
//Date format for dd-mm-yyyy betwwen 1900-01-01 and 2099-12-31 

"regex">(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d 
//finding word in a string..

"regex">^.*\b(one|two|three)\b.*$   //one,two,three may be your words...

//for deleting duplicate lines from text file...

"regex">^(.*)(\r?\n\1)+$
//For checking digits..

^[0-9]
//for checking alphabets...

^[a-z]
"regex">//REgular Expression for some Credit cards validations...

"regex">
//"Visa"

^[4]([0-9]{15}$|[0-9]{12}$)
//"MasterCard"

^[5][1-5][0-9]{14}$ 

//"Discover" 

^6011-?\\d{4}-?\\d{4}-?\\d{4}$

//"Diners Club" 

(^30[0-5][0-9]{11}$)|(^(36|38)[0-9]{12}$)

//"American Express" 

^[34|37][0-9]{14}$
"regex">
//"enRoute"

^(2014|2149)[0-9]{11}$

//"JCB" 

^3[0-9]{15}$)|(^(2131|1800)[0-9]{11}$)

Points of Interest

I like to Share my knowledge with you, because i am also one of you, taht if i don't know anything then i come to you...so keep excahnge of knowledge...

History

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

JustChiragPatel


Chirag Patel, a Programmer Analyst in a well known IT company working on .NET Technologies since last 2 years. He is interested in Pure business logic and fuzzy logic. his area of interest is in C#.NET, VB.NET and MSSQL 2005.

catch me on: http://groups.google.com/group/codewar
Occupation: Software Developer
Location: India India

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh)FirstPrevNext
Subject  Author Date 
NewsThere's a new version of the RegEx Tester Tool !memberBucanerO_Slacker0:21 2 Mar '08  
GeneralFormatting issuememberPete O'Hanlon0:32 23 Mar '07  
GeneralDon't be discouragedmemberBradml23:46 22 Mar '07  
GeneralWhat on earth?membernorm .net22:57 21 Mar '07  
GeneralRe: What on earth?memberpurplepangolin5:44 22 Mar '07  
GeneralRe: What on earth?membernorm .net5:50 22 Mar '07  
GeneralRe: What on earth?memberpurplepangolin6:04 22 Mar '07  
GeneralRe: What on earth?membernorm .net6:48 22 Mar '07  
GeneralRe: What on earth?memberpurplepangolin7:17 22 Mar '07  
GeneralRe: What on earth?memberJustChiragPatel18:31 22 Mar '07  
GeneralRe: What on earth?membernorm .net22:42 22 Mar '07  
GeneralRe: What on earth?membernorm .net22:41 22 Mar '07  
GeneralRe: What on earth?memberednrgc6:20 22 Mar '07  
GeneralRe: What on earth?membernorm .net6:49 22 Mar '07  
GeneralRe: What on earth?memberJustChiragPatel18:30 22 Mar '07  
GeneralRe: What on earth?membernorm .net22:40 22 Mar '07  
GeneralRe: What on earth?mvpJohn Simmons / outlaw programmer1:25 23 Mar '07  
GeneralRe: What on earth?membernorm .net2:19 23 Mar '07  
GeneralRe: What on earth?mvpJohn Simmons / outlaw programmer0:35 24 Mar '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 21 Mar 2007
Editor:
Copyright 2007 by JustChiragPatel
Everything else Copyright © CodeProject, 1999-2008
Web10 | Advertise on the Code Project