im struggling with the following scenario, i have a multiline string which has the word test multiple times inside, the string is:
Hello my name is "test" im a test
test is testing
i need to replace all the test -strings which are not in quotes every of the found ones should be followed by at least 1 whitespace OR a linebreak not by anything else, so the above string would transform into:
Hello my name is "test" im a HELLOWORLD
HELLOWORLD is testing
also the test -string could be prepended by whitespaces, but not also without.
What i already found out is a method to only replace a string which is not inside of quotes:
str.replace(/(test)(?=(?:[^"]|"[^"]*")*$)/, 'HELLOWORLD')
could sombebody give me a hand with finding the other rules?