text: Notepad++ Search and Replace From List With Limited Replacements
  I am looking for a way to search and replace a word from a list.
  I have 380 words that are “city” I want to place only 4 of the city words with “Sydney” and then move down my document and replace another 4 “city” words with “Melbourne”.
  Keep going down my document until all “city” words are replaced with my list of words.
  What would be the best way to achieve this?
  Thanks.
  - PeterJones last edited by
  What would be the best way to achieve this?
  My first reaction would be “use one of the scripting plugins, like PythonScript”
  There are examples in the forum of doing something similar using just regexes, by putting your list of words at the end of the document in a particular format, but that solution gets fragile if you’ve got a long document.
  If you’ve got a reasonably-short document (<1000 lines estimated), then can help you go down the regex route. If the document is longer, or if the list of cities requires more than about 1000 characters to list, then regex is not the right way, and we can help you with the script solution as well…
  However, before we can help, we would need a better indication of your data. Do an abbreviated version of your city list, like “Sydney, Melbourne, Adelaide”, and format up a short-but-representative block of text, which you will show using the
  </>button, so it ends up in a box like:
  this
  (If you have private data, share dummy values… as long as it has the same structure and “look”, it doesn’t have to be your real data)
  Show this block of text twice. Once in the original “before” state, where it has the “city” dummy text. The second time in the “after” state, with the replacements made. That way, we can see if we understand how your brief 2-sentence description matches your expected “before” and “after”.
  After following this advice, and letting us know the approximate size of both your document and the number of replacement cities, we might be able to give more directed help.
  I am also including my generic search/replace boilerplate, which reinforces some of what I’ve already said.
  ----
  It’s really a rather easy thing for a scripting plugin to do, as Peter says.
  Here’s a demo using PythonScript; see if you can follow its logic without further explanation:
  from Npp import editor city_string = ''' Sydney Melbourne Adelaide ''' city_list = city_string.splitlines() city_list.pop(0) for city in city_list: editor.replace('city', city, 0, 0, editor.getLength(), 4)