JavaScript RegExp Quantifier
- Previous Page *
- Next Page {X}
- Go to the Previous Level JavaScript RegExp Reference Manual
Definition and usage
n? Quantifier matches zero or one occurrences of n in any string.
Example
Global search for "1", followed by zero or one "0" character:
let text = "1, 100 or 1000?"; let pattern = /10?/g;
Syntax
new RegExp("n?")
Or abbreviated as:
/n?/
Modified syntax
new RegExp("n?", "g")
Or abbreviated as:
/n?/g
Browser Support
/n?/
Is ECMAScript1 (ES1) feature.
All browsers fully support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Support | Support | Support | Support | Support | Support |
- Previous Page *
- Next Page {X}
- Go to the Previous Level JavaScript RegExp Reference Manual