Regular Expressions for Validations

Regular Expressions for Validations

^[0-9]$      it allows only numbers without any limit

^[0-9]{0,10}$   it allows only numbers up-to  minimum 0 to  maximum 10 digits

^[0-9]{1,10}$   it allows only numbers up-to  minimum 1 to  maximum 10 digits

^[0-9.]{0,10}$   it allows only numbers and decimal numbers also up-to  minimum 1 to  maximum 10 digits

^[+]?\\d+(\\.{0,1}(\\d{0,3})\\%{0,1})?$   it allows +ve numbers only and also

 

^     allows(caret)

[]    specific numbers are symbols you want allow  like [0-9] it allows 0 to 9 all numbers

{}  specific limit for # chars appears in string {Min,Max}={0,1} means  in given String # may appears once or not appears

\\ this like OR condition

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: