Skip to main content
Email Password   helpLost your password?

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

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
NewsThere's a new version of the RegEx Tester Tool ! Pin
BucanerO_Slacker
0:21 2 Mar '08  
GeneralFormatting issue Pin
Pete O'Hanlon
0:32 23 Mar '07  
GeneralDon't be discouraged Pin
Bradml
23:46 22 Mar '07  
GeneralWhat on earth? Pin
norm .net
22:57 21 Mar '07  
GeneralRe: What on earth? Pin
purplepangolin
5:44 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
5:50 22 Mar '07  
GeneralRe: What on earth? Pin
purplepangolin
6:04 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
6:48 22 Mar '07  
GeneralRe: What on earth? Pin
purplepangolin
7:17 22 Mar '07  
GeneralRe: What on earth? Pin
JustChiragPatel
18:31 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
22:42 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
22:41 22 Mar '07  
GeneralRe: What on earth? Pin
ednrgc
6:20 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
6:49 22 Mar '07  
GeneralRe: What on earth? Pin
JustChiragPatel
18:30 22 Mar '07  
GeneralRe: What on earth? Pin
norm .net
22:40 22 Mar '07  
GeneralRe: What on earth? Pin
John Simmons / outlaw programmer
1:25 23 Mar '07  
GeneralRe: What on earth? Pin
norm .net
2:19 23 Mar '07  
GeneralRe: What on earth? Pin
John Simmons / outlaw programmer
0:35 24 Mar '07  


Last Updated 21 Mar 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009