<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Notepad++ Search and Replace From List With Limited Replacements]]></title><description><![CDATA[<p dir="auto">I am looking for a way to search and replace a word from a list.</p>
<p dir="auto">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”.</p>
<p dir="auto">Keep going down my document until all “city” words are replaced with my list of words.</p>
<p dir="auto">What would be the best way to achieve this?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20759/notepad-search-and-replace-from-list-with-limited-replacements</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 22:38:28 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20759.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Feb 2021 17:33:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Notepad++ Search and Replace From List With Limited Replacements on Thu, 18 Feb 2021 18:19:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/meathead" aria-label="Profile: Meathead">@<bdi>Meathead</bdi></a></p>
<p dir="auto">It’s really a rather easy thing for a scripting plugin to do, as Peter says.</p>
<p dir="auto">Here’s a demo using PythonScript; see if  you can follow its logic without further explanation:</p>
<pre><code class="language-z">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)

</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/63032</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63032</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 18 Feb 2021 18:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to Notepad++ Search and Replace From List With Limited Replacements on Thu, 18 Feb 2021 18:05:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/meathead" aria-label="Profile: Meathead">@<bdi>Meathead</bdi></a> ,</p>
<blockquote>
<p dir="auto">What would be the best way to achieve this?</p>
</blockquote>
<p dir="auto">My first reaction would be “use one of the scripting plugins, like PythonScript”</p>
<p dir="auto">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.</p>
<p dir="auto">If you’ve got a reasonably-short document (&lt;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…</p>
<p dir="auto">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 <code>&lt;/&gt;</code> button, so it ends up in a box like:</p>
<pre><code>this
</code></pre>
<p dir="auto">(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)</p>
<p dir="auto">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”.</p>
<p dir="auto">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.</p>
<p dir="auto">I am also including my generic search/replace boilerplate, which reinforces some of what I’ve already said.<br />
-—</p>
<p dir="auto"><em>Do you want regex search/replace help?  Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you.  All example text should be marked as literal text using the <code>&lt;/&gt;</code> toolbar button or manual <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">Markdown syntax</a>. To make <code>regex in red</code> (and so they keep their special characters like *), use backticks, like <code>`^.*?blah.*?\z`</code>. Screenshots can be pasted from the clipboard to your post using <code>Ctrl+V</code> to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have <strong>and</strong> the text you want to get from that data; include examples of things that <strong>should match</strong> and be transformed, <strong>and</strong> things that <strong>don’t match</strong> and should be left alone; show <strong>edge cases</strong> and make sure you examples are as <strong>varied</strong> as your real data.  Show the regex you already tried, <strong>and why</strong> you thought it should work; tell us what’s wrong with what you <strong>do</strong> get. Read the official <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">NPP Searching / Regex docs</a> and the forum’s <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Regular Expression FAQ</a>. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/63030</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63030</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 18 Feb 2021 18:05:15 GMT</pubDate></item></channel></rss>