I am using Nodejs to build application in which I need to process certain strings I have used the JS \"RegExp\" object for this purpose. I want only a part of my string in t
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).