However, you can't just add (?!\[) because it will backtrack and match only part of the variable. So to ensure that it will only match the whole variable and not part, add a \b (word boundary): s/(?<!\\)(\$[a-zA-Z0-9_]+)\b(?!\[)/whatever()/ge;(?!pattern) A zero-width negative lookahead assertion. For example /foo(?!bar)/ ma +tches any occurrence of ``foo'' that isn't followed by ``bar''.
In reply to Re: problem with substitution regex
by MrNobo1024
in thread problem with substitution regex
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |