Regular Expression in C#
Different Regular Expressions used in C# are.
White space is not allowed:
(\S)+
Alphabets and Space:
[a-zA-Z ]+$
Alphabets:
^[A-z]+$
Numbers:
^[0-9]+$
Alphanumeric:
^[a-zA-Z0-9]*$
Email Address:
[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 Number:
^([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})?$
^4[0-9]{12}(?:[0-9]{3})?$
MasterCard:
^5[1-5][0-9]{14}$
^5[1-5][0-9]{14}$
American Express:
^3[47][0-9]{13}$
^3[47][0-9]{13}$
Decimal number:
((\\d+)((\\.\\d{1,2})?))$
((\\d+)((\\.\\d{1,2})?))$
IFSC CODE:
^[^\s]{4}\d{7}$
^[^\s]{4}\d{7}$
PAN CARD:
^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$
^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$