Regular Expressions (regexp)

^ start of the string.
[1-9] excatly one digit of 1,2,3,4,5,6,7,8 or 9
\d{2} excatly two ocurrences of 0 to 9
? no or one occurence of a whitespace
\d{2} excatly two occurrences of 0 to 9
$ end of the string.

Two ways to create RegExp objects:

var regexp1 = /^[1-9]\d{2} ?\d{2}$/; //Literal
var regexp2 = new RegExp(“^[1-9]\d{2} ?\d{2}$”); // Constructor

Add your comment