Search w3schools.com:

SHARE THIS PAGE

JavaScript RegExp ^ Quantifier

RegExp Object Reference JavaSript RegExp Object

Definition and Usage

The ^n quantifier matches any string with n at the beginning of it.

Syntax

new RegExp("^n")

or

/^n/


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The ^ quantifier is supported in all major browsers.


Example

Example

Do a global search for "Is" at the beginning of a string:

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

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

Is this his

Try it yourself »


RegExp Object Reference JavaSript RegExp Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]