A search for "is" at the end of a string:
let text = "Is this his";
let pattern = /is$/;
Try it Yourself »
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.
/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 |
new RegExp("
n$")
or
/
n$/
new RegExp("
n$", "g")
or simply:
/
n$/g
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 »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!