Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RegExp ^ quantifier

JavaScript RegExp ^ quantifier

RegExp Object Reference The JavaScript RegExp object


Definition and Usage

^nThe quantifier matches any string beginning with n the specified string.

Syntax

new RegExp("^

n

")

or

/^

n

/


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the ^ quantifier.


Example

Example

Perform a global search for "Is" at the start of a string:

var str="Is this his";

var patt1=/^Is/g;

The text marked below shows where the expression found matches:

Is

this his

Try it »


RegExp Object Reference The JavaScript RegExp object