33.13.3 Regex Replace Error Message

While performing a regex replace function, if you specify /a, then, the following error message displays:

  • On Firefox browser: Incorrect syntax : invalid regular expression flag a

  • On Chrome browser: Incorrect syntax : Invalid flags supplied to RegExp constructor 'a'

To troubleshoot this issue, ensure that you specify a correct regular expression. For example: i (case insensitive), g (global search) are valid flags. A regular expression has the following format:

/pattern/modifiers. Example: var patt = /abc/i. Where, /abc/i is a regular expression and abc is a pattern (used in the search). i is a modifier (modifies the search to be case-insensitive).