<?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[another replacement request for help]]></title><description><![CDATA[<p dir="auto">Hello Notepad gurus,<br />
I am (also) looking for help with replacing several items in a file. I have searched and read a few other regex threads and although they help, I still cant find the way to do it.<br />
My problem is that the data is unformatted. For example, my file may contain these two lines in different places<br />
&lt;UWI&gt;AERY B 1H&lt;/UWI&gt;<br />
&lt;UWI&gt;ALEXANDER-WESSENDORFF 1 (SA) A3 A 3H&lt;/UWI&gt;</p>
<p dir="auto">And I need to replace what is inside of the &lt;UWI&gt;__&lt;/UWI&gt; using a table replacement (separated by tabs between the old and the new value)<br />
AERY B 1H    Aery #B1H<br />
ALEXANDER-WESSENDORFF 1 (SA) A3 A 3H    Alexander - Wessendorff 1 A3H</p>
<p dir="auto">So, on one hand, I have the advantage that the fields to replace are always within the &lt;UWI&gt;__&lt;/UWI&gt; and also that I have the replacement table formatted to be separated by tabs.</p>
<p dir="auto">But I am too new with this, so I can’t find a way to do it.<br />
Any help?<br />
Thanks in advance!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/19889/another-replacement-request-for-help</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 23:37:53 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19889.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 21 Aug 2020 14:12:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to another replacement request for help on Thu, 09 Sep 2021 22:50:18 GMT]]></title><description><![CDATA[<p dir="auto">Hello friends<br />
So one year later I had to do the same replacements, and found that the original script did not work anymore (Same error as reported by <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> ). Something must have changed in Notepad++, Python or somewhere else, because the first time it worked fine.</p>
<p dir="auto">Anyway, I updated the code as suggested by <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> and it worked correctly.<br />
Cheers everyone</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69588</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69588</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Thu, 09 Sep 2021 22:50:18 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Wed, 02 Sep 2020 17:14:24 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> and <strong>All</strong>,</p>
<p dir="auto"><strong>After</strong> tests, I confirmed that <strong>any</strong> kind of regex, like below :</p>
<p dir="auto">SEARCH <strong><code>(?is)(?&lt;=&lt;TEST&gt;)(.+?)(?=&lt;/TEST&gt;.+^---.+^\1\t(.+?)$)|^---.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\2</code></strong></p>
<p dir="auto">does <strong>not</strong> work properly ( 1 <strong>all</strong> contents <strong>match</strong> ! ) as soon as the <strong>scanned</strong> file contains more than <strong><code>200</code></strong> lines about :-(</p>
<hr />
<p dir="auto">Whereas your <strong>Python</strong> script, with the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>’s modification, works <strong>nice</strong> !</p>
<p dir="auto">Given the initial <strong><code>XML</code></strong> file, below, in <strong><code>new 1</code></strong> tab :</p>
<pre><code class="language-xml">&lt;Wellcollection&gt;
	&lt;Well replace="false"&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;Guy&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;00000&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;00001&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;00002&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
....
....
		&lt;TEST&gt;99998&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;99999&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
		&lt;TEST&gt;Guy&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection/&gt;
	&lt;/Well&gt;
&lt;/Wellcollection&gt;
</code></pre>
<p dir="auto">and the <strong><code>new_2</code></strong> contents, in secondary view :</p>
<pre><code class="language-z">BEFORE	After
Guy	Guy038
</code></pre>
<p dir="auto">and the <strong>python</strong> script :</p>
<pre><code class="language-py">from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    try:
        r = replacements[m.group()]
    except KeyError:
        r = m.group()
    return r

editor1.rereplace('(?&lt;=&lt;TEST&gt;).+?(?=&lt;/TEST&gt;)', replace_with)
</code></pre>
<p dir="auto">=&gt; On my <strong>old</strong> <strong><code>Win XP</code></strong> laptop, it took <strong><code>26s</code></strong> to execute :</p>
<ul>
<li>
<p dir="auto"><strong><code>100,000</code></strong> <strong>identical</strong> replacements ( from <strong><code>00000</code></strong> to <strong><code>99999</code></strong>  as <strong>not</strong> in the dictionary )</p>
</li>
<li>
<p dir="auto"><strong>2</strong> replacements from <strong><code>BEFORE</code></strong> to <strong><code>After</code></strong></p>
</li>
<li>
<p dir="auto"><strong>2</strong> replacements from <strong><code>Guy</code></strong> to <strong><code>Guy038</code></strong></p>
</li>
</ul>
<p dir="auto">So, a <strong>script</strong> solution is definitively the <strong>right</strong> solution to adopt to solve this <strong>general</strong> task !</p>
<p dir="auto">Best regards</p>
<p dir="auto">guy038</p>
<p dir="auto">However, in my example, it would be <strong>valuable</strong> to find out a method to <strong>avoid</strong> all these <strong>identical</strong> replacements ;-))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57285</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57285</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 02 Sep 2020 17:14:24 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Tue, 01 Sep 2020 12:29:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> and All,</p>
<p dir="auto">Like <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a>, I must had been <strong>tired</strong>, yesterday, while posting !</p>
<p dir="auto">Regarding the <strong>case</strong>’s problem, <strong>no</strong> need to <strong>re</strong>-run the script : Just run the following S/R, of course :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?i)Before</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>After</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">So, for all the <strong>remaining</strong> expressions which must be replaced, <strong>whatever</strong> their <strong>case</strong>, better to use the <strong>general</strong> regex :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?i)(Expression_1)|(Expression_2)|(Expression_3)....</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>(?1Replacement_1)(?2Replacement_2)(?3Replacement_3)...</code></strong></p>
</li>
</ul>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57249</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57249</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 01 Sep 2020 12:29:41 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 31 Aug 2020 21:09:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/57242">another replacement request for help</a>:</p>
<blockquote>
<p dir="auto">Now regarding the case’s problem,</p>
</blockquote>
<p dir="auto">Yes, I didn’t see a quick mod to the original script, and I didn’t want to alter its “simple elegance” to hack in casing support. Of course, it’s <em>possible</em> to do, but the original was such a work of art… :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57243</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57243</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 31 Aug 2020 21:09:53 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 31 Aug 2020 20:43:24 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> and All,</p>
<p dir="auto">I’ve <strong>just</strong> tried your solution, <strong>Alan</strong>,and it worked like a charm ;-)) <strong>Clever</strong> : when an entry is <strong>missing</strong> in the dictionary, the script simply rewrites the <strong>key</strong> value</p>
<p dir="auto">So, if you realize that you <strong>forgot</strong> some entries in the <strong><code>new 2</code></strong> file, ( so some <strong>replacements</strong> ! ), the easy workaround is :</p>
<ul>
<li>
<p dir="auto"><strong>Add</strong> all these <strong>new</strong> entries as well as their <strong>corresponding replacement</strong> parts</p>
</li>
<li>
<p dir="auto"><strong>Re</strong>-run the script</p>
</li>
</ul>
<hr />
<p dir="auto">Now regarding the <strong>case</strong>’s problem, we may run a <strong>regex</strong> S/R to get an <strong>unique</strong> case of an expression, <strong>before</strong> running the script</p>
<p dir="auto">For instance, instead of defining, in <strong><code>new 2</code></strong>, these <strong><code>5</code></strong>: entries</p>
<pre><code class="language-z">BEFORE	After
Before	After
before	After
BEFore	After
befORE	After
</code></pre>
<ul>
<li>
<p dir="auto">Firstly, we would use the regex S/R, against our text in <strong><code>new 1</code></strong> :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?i)Before</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\U$0</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">Secondly, we would <strong>re</strong>-run the <strong>Python</strong> script, with only <strong><code>1</code></strong> entry, in <strong><code>new 2</code></strong> :</p>
</li>
</ul>
<pre><code class="language-z">BEFORE	After
</code></pre>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57242</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57242</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 31 Aug 2020 20:43:24 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 31 Aug 2020 17:23:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a></p>
<p dir="auto">Yep, that is another solution as well.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57239</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57239</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 31 Aug 2020 17:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 31 Aug 2020 14:19:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@Ekopalypse</a> said in <a href="/post/57219">another replacement request for help</a>:</p>
<blockquote>
<p dir="auto">A solution concerning missing replacements is to replace with what was<br />
found or what I later suggested, creating unique search strings from the<br />
list of replacements.</p>
</blockquote>
<p dir="auto">Not sure about the “later suggest” part, but this seems like a quick solution to the former:</p>
<pre><code>def replace_with(m):
    try:
        r = replacements[m.group()]
    except KeyError:
        r = m.group()
    return r
</code></pre>
<p dir="auto">Disclaimer: I didn’t actually <em>try</em> it.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57229</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57229</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 31 Aug 2020 14:19:53 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 31 Aug 2020 10:58:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">thank you very much for checking the script.<br />
A solution concerning missing replacements is to replace with what was<br />
found or what I later suggested, creating unique search strings from the<br />
list of replacements.<br />
The first approach might work better for large files, the second seemed<br />
more reasonable at this point.</p>
<p dir="auto">To ignore case sensitivity - let’s changes the replacement keys to lower string<br />
and check against lower matches but replace with defined replacement values. So a replacement dictionary would look like this</p>
<pre><code class="language-py">    replacements = {'täst': 'TEST'}
</code></pre>
<p dir="auto">and would replace either Täst or täst with TEST always.</p>
<p dir="auto">Let me think about it again.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57219</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57219</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 31 Aug 2020 10:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Sun, 30 Aug 2020 19:10:53 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> and <strong>All</strong>,</p>
<p dir="auto">Just back from some <strong>holidays</strong> in Brittany ! <strong>Good</strong> day to everybody ;;-))</p>
<p dir="auto">Looking back to your <strong>first</strong> script, of this discussion, it solves an interesting and <strong>general</strong> task :</p>
<ul>
<li>
<p dir="auto">Given a <strong>first</strong> file, where some <strong>words / expressions</strong> must be <strong>replaced</strong></p>
</li>
<li>
<p dir="auto">Given a <strong>second</strong> file containing <strong>all</strong> these the words / expressions and their <strong>corresponding</strong> replacements with a <strong>tabulation</strong> as a <strong>separator</strong></p>
</li>
</ul>
<p dir="auto">This script executes, in the <strong>first</strong> file, all in <strong>once</strong>, the <strong>different</strong> replacements, from the <strong>second</strong> file’s table ;-))</p>
<hr />
<p dir="auto">Now, considering the <strong>slightly</strong> modified script, where the <strong>range</strong> of chars searched is contained in tags <strong><code>&lt;TEST&gt;......&lt;/TEST&gt;</code></strong></p>
<pre><code class="language-py">from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    return replacements[m.group()]

editor1.rereplace('(?&lt;=&lt;TEST&gt;).+?(?=&lt;/TEST&gt;)', replace_with)
</code></pre>
<p dir="auto">May I ask you about <strong>two</strong> questions :</p>
<ul>
<li>When the file to be modified ( <strong><code>new1</code></strong> ) contains, in a tag <strong><code>&lt;TEST&gt;......&lt;/TEST&gt;</code></strong>, a value <strong>not</strong> listed in the <strong><code>new 2</code></strong> file, the scripts stops, <strong>no</strong> replacement occurs and the console message <strong><code>KeyError: 'ABCDE'</code></strong> is displayed</li>
</ul>
<p dir="auto">Example, with <strong><code>new 1</code></strong> :</p>
<pre><code class="language-xml">&lt;Wellcollection&gt;
	&lt;Well replace="false"&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;And BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;ABCDE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
</code></pre>
<p dir="auto">and <strong><code>new 2</code></strong></p>
<pre><code class="language-z">BEFORE	After
And BEFORE	After
</code></pre>
<p dir="auto">Could it be possible to avoid errors for all <strong>key</strong> values <strong>not</strong> listed in <strong><code>new 2</code></strong> ?</p>
<hr />
<ul>
<li>Secondly, how to ignore <strong>case</strong> of the <strong>key</strong> values ? I mean, instead of he <strong>obvious</strong> method, below, in <strong><code>new 2</code></strong></li>
</ul>
<pre><code class="language-z">BEFORE	After
And BEFORE	After
and before	After
</code></pre>
<p dir="auto">I tried this version, <strong>without</strong> success :</p>
<pre><code class="language-py">from Npp import editor1, editor2
import re

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    return replacements[m.group()]

editor1.rereplace('(?&lt;=&lt;TEST&gt;).+?(?=&lt;/TEST&gt;)', replace_with, re.IGNORECASE)
</code></pre>
<p dir="auto">with <strong><code>new 1</code></strong> :</p>
<pre><code class="language-xml">&lt;Wellcollection&gt;
	&lt;Well replace="false"&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;And BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;and before&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;

</code></pre>
<p dir="auto">and <strong><code>new 2</code></strong> :</p>
<pre><code class="language-z">BEFORE	After
And BEFORE	After
</code></pre>
<p dir="auto">I still had the error :</p>
<p dir="auto"><strong><code>KeyError: 'and before'</code></strong></p>
<p dir="auto">TIA,</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto">Afterwards, I’ll do <strong>additional</strong> tests with your <strong>script</strong> and the <strong>regex</strong> S/R solution, below :</p>
<p dir="auto">SEARCH <strong><code>(?is)(?&lt;=&lt;TEST&gt;)(.+?)(?=&lt;/TEST&gt;.+^---.+^\1\t(.+?)$)|^---.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\2</code></strong></p>
<p dir="auto">This S/R executed against this text :</p>
<pre><code class="language-z">&lt;Wellcollection&gt;
	&lt;Well replace="false"&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;And BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;and before&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;And BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;BEFORE&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
---
BEFORE	After
And BEFORE	After 2
</code></pre>
<p dir="auto">gives this <strong>changed</strong> text :</p>
<pre><code class="language-z">&lt;Wellcollection&gt;
	&lt;Well replace="false"&gt;
		&lt;TEST&gt;After&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;After 2&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;After 2&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;After 2&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
		&lt;TEST&gt;After&lt;/TEST&gt;
		&lt;WellType&gt;Oil&lt;/WellType&gt;
		&lt;ReserveStatusCollection&gt;
</code></pre>
<p dir="auto">I bet that your script can manage <strong>largest</strong> files than my <strong>regex</strong> solution !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57173</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57173</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 30 Aug 2020 19:10:53 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 28 Aug 2020 20:44:36 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@Ekopalypse</a> I still owe you a beer<br />
I’m sure i’ll come and ask questions again, so maybe more than a beer haha</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57164</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57164</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Fri, 28 Aug 2020 20:44:36 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 24 Aug 2020 11:00:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@Ekopalypse</a> said in <a href="/post/57059">another replacement request for help</a>:</p>
<blockquote>
<p dir="auto">&lt;UWI&gt;(.*)&lt;/UWI&gt;(?s)(\R.+?)&lt;PrimaryProduct&gt;\K.+?(?=&lt;/PrimaryProduct&gt;)</p>
</blockquote>
<p dir="auto">to be used in the script it would be</p>
<pre><code class="language-py">'&lt;UWI&gt;({})&lt;/UWI&gt;(?s)(\R.+?)&lt;PrimaryProduct&gt;\K.+?(?=&lt;/PrimaryProduct&gt;)'
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/57062</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57062</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 24 Aug 2020 11:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Mon, 24 Aug 2020 10:39:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<blockquote>
<p dir="auto">I’m sure there are better ways to jump three lines,</p>
</blockquote>
<p dir="auto">In the end, what really counts is whether it does what it is supposed to do, right?<br />
One, of several alternatives would be for example</p>
<p dir="auto"><code>&lt;UWI&gt;(.*)&lt;/UWI&gt;(?s)(\R.+?)&lt;PrimaryProduct&gt;\K.+?(?=&lt;/PrimaryProduct&gt;)</code></p>
<p dir="auto">but whether this is better or worse depends on the real data.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57059</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57059</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Mon, 24 Aug 2020 10:39:31 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 22:30:31 GMT]]></title><description><![CDATA[<p dir="auto">By the way, I went back and edited the script to run a second time looking for another instance below.</p>
<p dir="auto">I’m sure there are better ways to jump three lines, but it’s late and I needed to finish. It worked! haha</p>
<pre><code>from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    return replacements[m.group(1)]

# search_for = '(?&lt;=&lt;UWI&gt;).+?(?=&lt;/UWI&gt;)'
for company in replacements.keys():
    search_for = '&lt;UWI&gt;({})&lt;/UWI&gt;\R\h*.*\R\h*.*\R\h*.*\R\h*&lt;PrimaryProduct&gt;\K.+?(?=&lt;/PrimaryProduct&gt;)'.format(company)
    editor1.rereplace(search_for, replace_with)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/57013</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57013</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Fri, 21 Aug 2020 22:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 22:14:09 GMT]]></title><description><![CDATA[<p dir="auto">The first one worked!<br />
Thanks so much for your help, I owe you a beer!<br />
Have a good night</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57012</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57012</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Fri, 21 Aug 2020 22:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 22:11:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<p dir="auto">depending on the file size a faster solution might be this</p>
<pre><code class="language-py">from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    company = replacements.get(m.group(1), None)
    if company:
        return replacements[m.group(1)]
    else:
        return m.group()

# search_for = '(?&lt;=&lt;UWI&gt;).+?(?=&lt;/UWI&gt;)'
search_for = '&lt;UWI&gt;(.+)&lt;/UWI&gt;\R\h*&lt;WellType&gt;\K.+?(?=&lt;/WellType&gt;)'
editor1.rereplace(search_for, replace_with)
</code></pre>
<p dir="auto">Only scanning the text one time and in case the company found is<br />
not in the replacements dictionary we replace it with what was found.<br />
Btw. its midnight here - good night.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57011</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57011</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 22:11:40 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:54:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<pre><code class="language-py">from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    return replacements[m.group(1)]

# search_for = '(?&lt;=&lt;UWI&gt;).+?(?=&lt;/UWI&gt;)'
for company in replacements.keys():
    search_for = '&lt;UWI&gt;({})&lt;/UWI&gt;\R\h*&lt;WellType&gt;\K.+?(?=&lt;/WellType&gt;)'.format(company)
    editor1.rereplace(search_for, replace_with)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/57009</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57009</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:54:47 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:52:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<p dir="auto">Yes, that makes sense then we need to take another approach where we<br />
create the searches based on the second list. Gimme a minute</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57008</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57008</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:52:03 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:51:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@Ekopalypse</a> here is the log.<br />
I think it is because not all the wells need to be changed, so the first one in the file (Aery #B1H) does not appear in the second file, so the script is stopping. I will try leaving all wells, even those that doesnt need to be changed</p>
<p dir="auto">Traceback (most recent call last):<br />
File “C:\Users\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\find_replace.py”, line 10, in &lt;module&gt;<br />
editor1.rereplace(search_for, replace_with)<br />
File “C:\Users\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts\find_replace.py”, line 6, in replace_with<br />
return replacements[m.group(1)]<br />
KeyError: ‘Aery #B1H’</p>
<p dir="auto">And yes, the other file is separated by tabs.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57007</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57007</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:51:41 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:47:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<p dir="auto">Can you open the PythonScript console (plugin-&gt;PythonScript-&gt;Show Console) to see if there is an error?<br />
The replacement file has company and gas/oil tab separated, correct?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57006</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57006</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:47:12 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:41:22 GMT]]></title><description><![CDATA[<p dir="auto">Thanks again for your help.<br />
For some reason this time it isn’t working.<br />
I will try and fix it.</p>
<p dir="auto"><img src="/assets/uploads/files/1598046075093-a4f54196-4f8f-444f-a7b7-15048ba35f66-image.png" alt="a4f54196-4f8f-444f-a7b7-15048ba35f66-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/57003</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57003</guid><dc:creator><![CDATA[Carlos J. Segnini R.]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:41:22 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:17:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<p dir="auto">btw. if you are interested how these regex search work see <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">here</a> for a pretty good description.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57001</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57001</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:12:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<pre><code class="language-py">from Npp import editor1, editor2

replacements = dict(line.split('\t') for line in editor2.getText().splitlines() if line)

def replace_with(m):
    return replacements[m.group(1)]

# search_for = '(?&lt;=&lt;UWI&gt;).+?(?=&lt;/UWI&gt;)'
search_for = '&lt;UWI&gt;(.+)&lt;/UWI&gt;\R\h*&lt;WellType&gt;\K.+?(?=&lt;/WellType&gt;)'
editor1.rereplace(search_for, replace_with)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/57000</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57000</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:12:59 GMT</pubDate></item><item><title><![CDATA[Reply to another replacement request for help on Fri, 21 Aug 2020 21:08:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/19583">@Carlos-J-Segnini-R</a></p>
<p dir="auto">so you can get rid of the second column and the only thing we need to change is the find expression, I guess.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/56999</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/56999</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Fri, 21 Aug 2020 21:08:00 GMT</pubDate></item></channel></rss>