JavaScript RegExp ^ Quantifier
Example
A global search for "Is" at the beginning of a string:
let text = "Is this his";
let pattern = /^Is/g;
Try it Yourself »
Definition and Usage
The ^n quantifier matches any string with n at the beginning of it.
Tip: Use the n$ quantifier to match any string with n at the END of it.
Browser Support
/^n/
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
new RegExp("^n")
or
/^n/
Syntax with modifiers
new RegExp("^n", "g")
or simply:
/\^n/g
More Examples
Example
A global, case-insensitive, multiline search for "is" at the beginning of each line:
let text = `Is this
all there
is`
let pattern = /^is/gmi;
Try it Yourself »