Monday 11 March 2013

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

No comments:

Post a Comment