Skip to main content

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}?$

Comments

Popular posts from this blog

IList in C#

Lists and arrays implement IList. This interface is an abstraction that allows list types to be used with through a single reference type. Properties of IList Few popular property of IList interface is given below. Count:-  It will return number of object in List IsReadOnly:- This property will indicate whether the IList is read-only or not. Item:- It will return the particular Item of specified index. Example :-  For calling this class method in void Main. Final Output :-  

List in C#

The Collection classes are a group of classes designed specifically for grouping together objects and performing tasks on them. List class is a collection and defined in the System. Collections.Generic namespace and it provides the methods and properties like other Collection classes such as add, insert, remove, search etc. The C# List < T > class represents a strongly typed list of objects that can be accessed by index and it supports storing values of a specific type without casting to or from object. Referred from :- http://csharp.net-informations.com/collection/list.htm Download Code from below link :- https://app.box.com/s/kplszfmpooytythic1b29u85uhiffo9s Example :-  For calling this class method in void Main. Final output :-

ArrayList in C#

Whats is Arraylist? ArrayList is NOT Fixed Length. ArrayList is NOT Strongly Typed. ArrayList can accept string, integer and decimal Simultaneously. Download Code from below link :- https://app.box.com/s/kplszfmpooytythic1b29u85uhiffo9s I am mainly focusing on Example. Example :-  Here i am using ArrayList . For adding and retrieving rows from Array I am using For loop and Foreach loop. TestArrayList :- is class name Method name :- myArraylist() For calling this class method in Void Main.  Final output :-