Do a global search for a "1", followed by zero or one "0" characters:
let text = "1, 100 or 1000?";
let pattern = /10?/g;
Try it Yourself »
The n? quantifier matches any string that contains zero or one occurrences of n.
/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 simply:
/
n?/
new RegExp("
n?", "g")
or simply:
/
n?/g
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!