I use a regular expression to replace ( in other regular expressions (or regular expressions?) With (?: To turn them into inconsistent groups. My expression assumes no structures are used (?X and looks like this:
( [^\\] - Not backslash character |^ - Or string beginning ) (?: [\(] - a bracket )
Unfortunately, this will not work if in this case there are two matches, as in this case: how((\s+can|\s+do)(\s+i)?)?

With lookbehinds, the solution is easy:
/(?<=[^\\]|^)[\(]/g
But javascript does not support lookbehinds, so what can I do? My searches have not brought any simple universal alternative to lookbehind.
javascript regex
Tomáš zato
source share