lundi 22 décembre 2014

how to write a regular expression to validate this string


I have a string E.g 1001, which needs to be exactly 4 chars and can be any combination of 0 and 1, but not all zeros (all ones is ok).


I thought of:



^[01]{4}$


won't work because it accepts 0000


I will be using PHP or JavaScript to do this.





Aucun commentaire:

Enregistrer un commentaire