Part of String Case Insensitive in JavaScript Regex (?i) option not working

JavaScript built-in RegExp does not support inline modifiers, like (?im), let alone inline modifier groups that can be placed anywhere inside the pattern (like (?i:....)).

Even XRegExp cannot offer this functionality, you can only use (?i) on the whole pattern declaring it at the pattern beginning.

In XRegExp, you can define the regex ONLY as

var regex = XRegExp('(?i)\\{(\\b' + key +'\\b:?.*?)\\}', 'g');

On May 27, 2020, still neither JavaScript native RegExp, nor XRegExp patterns support inline modifier groups (i.e. (?i:...)), nor placing them in any part of the pattern (as far as XRegExp is concerned).

Leave a Comment