Regular expressions (regexps) are patterns which describe the contents of a string. They're used for testing whether a string contains a given pattern, or extracting the portions that match.
?
The ?
(quantifier) makes the preceding token in the regular expression optional
# matches both colour and color colou?r # matches Nov and November Nov(ember)?
const method1 = new RegExp(/^---([\s\S]*?)---/).exec(someString); const method2 = someString.match(/^---([\s\S]*?)---/);