1

I want to do a "bulk" search and replace (notepad++) in many text files but that search and replace has to be "intelligent" and do the replacement in the following way:

I search for a pattern "source" and want to replace with "target". The search for "source" should be without check upper/lower - so the search should find "Source", "source" or "SOURCE"

The automatic replacement then should be done in the following way:

"Source" -> "Target"
"source" -> "target"
"SOURCE" -> "TARGET"

Is that possible? And if yes, how to do it?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
rocholz
  • 19
  • 1
  • 1
    Does this answer your question? [Multiple word search and replace in notepad++](https://stackoverflow.com/questions/11389466/multiple-word-search-and-replace-in-notepad) – AdrianHHH Jul 11 '21 at 08:04
  • Using Regex might help, though I haven't used it myself with notepad++. I believe it was referenced in the linked question above. regex101.com, youtube tutorials, and using it with a language helped me learn it relatively quickly. – pyknight202 Jul 12 '21 at 01:29
  • What to do when the length of `soure` is different from the length of `target`? – Toto Jul 14 '21 at 09:56

1 Answers1

-2

Every programming language is case sensitive like python, C etc., so:

    with open("nameofdocu.txt") as f:
    data = f.read()
    change = input("Type a word you want to replace")
    if(change == Source):
      data.replace(Source,Target)
    elif(change == source):
      data.replace(source,target)
    elif(change == SOURCE)
      data.replace(SOURCE,TARGET)
pyknight202
  • 1,415
  • 1
  • 5
  • 22
  • Hi, your answer is not, what i am looking for. Of course - i can program a search and replace function, but i want to understand if it is possible with the help of notepad++ to solve my problem. Again: i am looking for a case SENSITIVE REPLACE of a case INSENSITIVE SEARCH. Example: I define a case INSENSITIVE Search for the term "source". Notepad++ should find all occurences of "source" - example: Source, source, sOUrce. Then Notepad++ (or a plugin) should replace the search results in case SENSITIVE way into: "source" -> "target", "Source"-> "Target", "sOUrce" -> "tARget". Understand? – rocholz Jul 11 '21 at 17:08