0

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
1
  • 1
    there is no s modifier in javascript regex Commented May 14, 2016 at 5:11

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.