Latest

recent

JavaScript RegExp {x,y} Modifier

Definition and Usage

When the {x,y} modifier is set the regular expression finds a number of regular expressions grouped together within a number range.
The x and y characters inside the brackets must be numbers and specifies the number range (x = from, y = to).

Syntax

/regexp{x,y}/

Parameter Description
regexp Required. The rest of the regular expression to use


Example

In the following code we will do a global search for any substring with between three and four digits:

var str = "100 or 1000?";
var patt1 = /\d{3,4}/g;

The marked text below shows where the RegExp gets a match:

100 or 1000?
JavaScript RegExp {x,y} Modifier Reviewed by 1000sourcecodes on 21:43 Rating: 5
Powered by Blogger.