Quantcast
Viewing latest article 2
Browse Latest Browse All 3

Answer by rollingcodes for RegEx Return found Group IF String Does NOT start with ' - VSCode - Search/Replace

This should do the trick:

Replace\{\{(?:\s|\n)*(?!(?:'|\s|\n))(.*')(?:\s|\n)*(\|(?:\s|\n)+translate)\b

with{{ '$1 $2

Regex 101 Demo

Explanation:

  • \{\{ - match two open braces

  • (?:\s|\n)* - match any number of whitespace characters

  • (?!(?:'|\s|\n))(.*') - capture group 1; match any continuous string of not ' characters followed by a single '

  • (?:\s|\n)* - match any number of whitespace characters

  • (\|(?:\s|\n)+translate) - capture group 2; match | followed by at least one, or more, whitespace character and then the word translate.

  • \b - match a word boundary


Viewing latest article 2
Browse Latest Browse All 3

Trending Articles