Sunday, 13 August 2017

Useful Regular Expression in C#.

Useful Regular Expression in C#.

White space is not allowed 
(\S)+

Alphabets and Space
[a-zA-Z ]+$

Alphabets
^[A-z]+$

Numbers
^[0-9]+$

Alphanumeric
^[a-zA-Z0-9]*$

Email
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

Mobile no.
^([7-9]{1})([0-9]{9})$

Date Format ( mm/dd/yyyy | mm-dd-yyyy | mm.dd.yyyy )

/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d+$/

Website URL
^http(s)?://([\\w-]+.)+[\\w-]+(/[\\w- ./?%&=])?$

Credit Card Numbers
Visa
^4[0-9]{12}(?:[0-9]{3})?$ 

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

American Express
^3[47][0-9]{13}$ 

Decimal number
((\\d+)((\\.\\d{1,2})?))$  

IFSC CODE
^[^\s]{4}\d{7}$

PAN CARD
^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...