Reputation: 510
Is it possible to have regex with both g
and s
modifier?
I've tried
/abc/gs // throw error
new RegExp('abc', 'g', 's') // s is ignored
new RegExp('abc', 'gs') // throw error
new RegExp('abc', ['g', 's']) // throw error
Upvotes: 0
Views: 3120
Reputation: 115222
You can get the answer from the error thrown
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'gs'(…)
There is no s
modifier in JavaScript regex. So it's an invalid regex that's why it's throwing error. The available modifiers can be check on documentation.
Upvotes: 4