JavaScript RegExp ^Quantifier

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

^nThe quantifier matches any string that begins withnthe 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 beginning of the string:

var str="Is this his";
var patt1=/^Is/g;

Belowmarkedtext shows where the expression obtained a match:

Is this his

Try it Yourself »


RegExp 对象参考手册JavaScript RegExp Object Other Extensions