- Ctrl+H
- Finden:
(?:^(?<!#).*\K|(<?!"))\bhat\b(?!")
- Ersetzen:
llama
- Überprüfen Sie den regulären Ausdruck
- Ganzes Wort prüfen
- Wrap überprüfen
- Replace all
Erläuterung:
(?: ^ : beginning of line (?<!#) : negative lookbehind, zero-length assertion that makes sure we don't have # before .* : 0 or more any character \k : forget all we have seen until this position | : OR (?<!") : negative lookbehind, zero-length assertion that makes sure we don't have " before ) \b : word boundary to not match chat, remove it if you want to match chat also hat : literally \b : word boundary to not match hats, remove it if you want to match hats also (?!") : negative lookahead, zero-length assertion that makes sure we don't have " after
Gegeben:
# Where did my hat go? hat = 0 chat = 0 print(hat) print("hat") print(chat)
Ergebnis für gegebenes Beispiel:
# Where did my hat go? llama = 0 chat = 0 print(llama) print("hat") print(chat)
Vor: