Este faz o trabalho:
Assigned Workgroup.*?"\KBusiness Service Management(?="[^)]*\))
Explicação:
Assigned Workgroup : literally
.*? : 0 or more any character, not greedy
" : a double quote
\K : forget all we have seen until this position
Business Service Management : literally
(?= : positive lookahead
" : a double quote
[^)]* : 0 or more anyy character that is not a close parenthesis
\) : a close parenthesis
) : end lookahead
Uso:
Usando o perl
my $str = <<EOD;
project in (KISHORE_TEST, "Business Service Management") AND "Assigned Workgroup" in (KISHORE_TEST,"Business Service Management", "Account","BSM Automation") OR "Workgroup" in ("BSM Automation") OR "Assigned Workgroup" in ("Business Service Management","BSM Automation") OR "Assigned Workgroup" in ("BSM Automation") and team = "Business Service Management"
EOD
$str =~ s/Assigned Workgroup.*?"\KBusiness Service Management(?="[^)]*\))/new_string/g;
say $str;
Saída:
project in (KISHORE_TEST, "Business Service Management") AND "Assigned Workgroup" in (KISHORE_TEST,"new_string", "Account","BSM Automation") OR "Workgroup" in ("BSM Automation") OR "Assigned Workgroup" in ("new_string","BSM Automation") OR "Assigned Workgroup" in ("BSM Automation") and team = "Business Service Management"
Isso funcionará com o php e com o Notepad ++ e com muitos idiomas / ferramentas que usam o sabor de regex do PCRE.
Se você tiver algumas dificuldades com o lookaround, você pode usar:
- Localizar:
(Assigned Workgroup.*?")Business Service Management("[^)]*\))
- Substituir:
$1new_string$2