Example: https://jsfiddle.net/zzby5zb6/1/
Actually, this isn't technically incorrect, as the replace function has no way of knowing if the intention was to put the !!! inside of the span element or outside of it.
As far as I understand, this is limited by the current design. I understand your desire to stay true to the original regexp/replace syntax, but to avoid such scenarios, maybe it would make sense to consider using capture group delimiters? Being able to express something like {$1!!!}{$2} would solve the issue.
Example: https://jsfiddle.net/zzby5zb6/1/
Actually, this isn't technically incorrect, as the
replacefunction has no way of knowing if the intention was to put the!!!inside of thespanelement or outside of it.As far as I understand, this is limited by the current design. I understand your desire to stay true to the original regexp/replace syntax, but to avoid such scenarios, maybe it would make sense to consider using capture group delimiters? Being able to express something like
{$1!!!}{$2}would solve the issue.