JavaScript RegExp $ Quantifier
Example
A search for "is" at the end of a string:
let text = "Is this his";
let pattern = /is$/;
Try it Yourself »
Definition and Usage
The n$ quantifier matches any string with n at the end of it.
Tip: Use the ^n quantifier to match any string with n at the BEGINNING of it.
Browser Support
/n$/
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
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, multiline search for "is" at the end of each line:
let text = `Is this
all there
is`
let pattern = /is$/gm;
Try it Yourself »