<?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[Replace strings with specific lines content]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">I have the following file</p>
<pre><code>45415
7684
124
6845
3210
16
785
8651
245
8521
&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
	&lt;RuleList&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;100&lt;/Action&gt;
			&lt;Applications&gt;pid=4323&lt;/Applications&gt;
			&lt;Name&gt;Nox0&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;101&lt;/Action&gt;
			&lt;Applications&gt;pid=12&lt;/Applications&gt;
			&lt;Name&gt;Nox1&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;102&lt;/Action&gt;
			&lt;Applications&gt;pid=87654&lt;/Applications&gt;
			&lt;Name&gt;Nox2&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;103&lt;/Action&gt;
			&lt;Applications&gt;pid=345&lt;/Applications&gt;
			&lt;Name&gt;Nox3&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;104&lt;/Action&gt;
			&lt;Applications&gt;pid=936&lt;/Applications&gt;
			&lt;Name&gt;Nox4&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;105&lt;/Action&gt;
			&lt;Applications&gt;pid=54734&lt;/Applications&gt;
			&lt;Name&gt;Nox5&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;106&lt;/Action&gt;
			&lt;Applications&gt;pid=6435&lt;/Applications&gt;
			&lt;Name&gt;Nox6&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;107&lt;/Action&gt;
			&lt;Applications&gt;pid=95325&lt;/Applications&gt;
			&lt;Name&gt;Nox7&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;108&lt;/Action&gt;
			&lt;Applications&gt;pid=10&lt;/Applications&gt;
			&lt;Name&gt;Nox8&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;109&lt;/Action&gt;
			&lt;Applications&gt;pid=000992&lt;/Applications&gt;
			&lt;Name&gt;Nox9&lt;/Name&gt;
		&lt;/Rule&gt;
	&lt;/RuleList&gt;
</code></pre>
<p dir="auto">There are multiple pid=xxxx in the file. I need to replace each xxxx with the numbers on the first 10 lines (each line would replace a xxxx). How can I achieve this? Can it be done with Find and replace?</p>
<p dir="auto">I have absolutely no idea about regex (first time I heard about that) but investigating I managed to produce (?&lt;=&gt;pid=).+?(?=&lt;/A) to match what I need to replace in “Find What”, but I don’t know what to put in “Replace with” to capture the numbers in the beginning of the file.</p>
<p dir="auto">Any help would be greatly appreciated.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22510/replace-strings-with-specific-lines-content</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 08:39:26 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22510.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Feb 2022 04:50:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace strings with specific lines content on Mon, 07 Feb 2022 19:54:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/andres-garzon" aria-label="Profile: andres-garzon">@<bdi>andres-garzon</bdi></a> said in <a href="/post/73858">Replace strings with specific lines content</a>:</p>
<blockquote>
<p dir="auto">is there any way to put all these steps into a macro?</p>
</blockquote>
<p dir="auto">IMO it would be insane to try to record that as a macro, or to even hand-edit a macro to try to do it.</p>
<p dir="auto">I wouldn’t have written to just say that though.  I wanted to point out a specific thing as I look over the list of what Guy gave you.</p>
<p dir="auto">I see:</p>
<ul>
<li>Click on the Copy Marked Text button</li>
</ul>
<p dir="auto">I’ve noticed that this button on the <em>Mark</em> window isn’t macro-recordable.  :-(</p>
<p dir="auto">But… happily, this is the equivalent command and it IS macro-recordable:</p>
<p dir="auto"><img src="/assets/uploads/files/1644263634743-d8be9717-a3e2-48c5-8a07-39be38dd4e02-image.png" alt="d8be9717-a3e2-48c5-8a07-39be38dd4e02-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">As to the rest…good luck with the macroizing!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73862</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73862</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 07 Feb 2022 19:54:13 GMT</pubDate></item><item><title><![CDATA[Reply to Replace strings with specific lines content on Mon, 07 Feb 2022 19:25:44 GMT]]></title><description><![CDATA[<p dir="auto">Wonderful, worked like a charm!</p>
<p dir="auto">Now, is there any way to put all these steps into a macro? I tried doing all the steps while recording macro but when I run it, it doesn’t work;</p>
<p dir="auto">Thank you</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73858</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73858</guid><dc:creator><![CDATA[Andres Garzon]]></dc:creator><pubDate>Mon, 07 Feb 2022 19:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to Replace strings with specific lines content on Mon, 07 Feb 2022 21:19:54 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/andres-garzon" aria-label="Profile: andres-garzon">@<bdi>andres-garzon</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Here is a solution using <strong>regexes</strong>, of course !</p>
<p dir="auto">Just follow this <strong>road map</strong>. It may appear a bit <strong>complicated</strong> but it doesn’t take much time to get the <strong>correct</strong> results !</p>
<p dir="auto">So :</p>
<ul>
<li>
<p dir="auto">First, copy your <strong><code>XML</code></strong> text in a <strong>new</strong> tab</p>
</li>
<li>
<p dir="auto">Add a line of, at least, <strong>five</strong> <strong><code>=</code></strong> signs</p>
</li>
<li>
<p dir="auto"><strong>Append</strong> your list of <strong>numbers</strong>, one per line</p>
</li>
</ul>
<p dir="auto">You should obtain this layout :</p>
<pre><code class="language-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
	&lt;RuleList&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;100&lt;/Action&gt;
			&lt;Applications&gt;pid=4323&lt;/Applications&gt;
			&lt;Name&gt;Nox0&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;101&lt;/Action&gt;
			&lt;Applications&gt;pid=12&lt;/Applications&gt;
			&lt;Name&gt;Nox1&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;102&lt;/Action&gt;
			&lt;Applications&gt;pid=87654&lt;/Applications&gt;
			&lt;Name&gt;Nox2&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;103&lt;/Action&gt;
			&lt;Applications&gt;pid=345&lt;/Applications&gt;
			&lt;Name&gt;Nox3&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;104&lt;/Action&gt;
			&lt;Applications&gt;pid=936&lt;/Applications&gt;
			&lt;Name&gt;Nox4&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;105&lt;/Action&gt;
			&lt;Applications&gt;pid=54734&lt;/Applications&gt;
			&lt;Name&gt;Nox5&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;106&lt;/Action&gt;
			&lt;Applications&gt;pid=6435&lt;/Applications&gt;
			&lt;Name&gt;Nox6&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;107&lt;/Action&gt;
			&lt;Applications&gt;pid=95325&lt;/Applications&gt;
			&lt;Name&gt;Nox7&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;108&lt;/Action&gt;
			&lt;Applications&gt;pid=10&lt;/Applications&gt;
			&lt;Name&gt;Nox8&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;109&lt;/Action&gt;
			&lt;Applications&gt;pid=000992&lt;/Applications&gt;
			&lt;Name&gt;Nox9&lt;/Name&gt;
		&lt;/Rule&gt;
	&lt;/RuleList&gt;
=====
45415
7684
124
6845
3210
16
785
8651
245
8521
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Open the <strong>Mark</strong> dialog ( <strong><code>Ctrl + M</code></strong> )</p>
</li>
<li>
<p dir="auto">MARK <strong><code>(?&lt;=pid=)\d+|^\d+$|^=====</code></strong></p>
</li>
<li>
<p dir="auto">Untick <strong>all</strong> options</p>
</li>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Mark All</code></strong> button</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Copy Marked Text</code></strong> button</p>
</li>
<li>
<p dir="auto"><strong>Select</strong> your list of numbers, <strong>after</strong> the line of <strong>equal</strong> signs</p>
</li>
<li>
<p dir="auto"><strong>Replace</strong> by the result of marking ( <strong><code>Ctrl + V</code></strong> )</p>
</li>
</ul>
<p dir="auto">Giving the following text :</p>
<pre><code class="language-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
	&lt;RuleList&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;100&lt;/Action&gt;
			&lt;Applications&gt;pid=4323&lt;/Applications&gt;
			&lt;Name&gt;Nox0&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;101&lt;/Action&gt;
			&lt;Applications&gt;pid=12&lt;/Applications&gt;
			&lt;Name&gt;Nox1&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;102&lt;/Action&gt;
			&lt;Applications&gt;pid=87654&lt;/Applications&gt;
			&lt;Name&gt;Nox2&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;103&lt;/Action&gt;
			&lt;Applications&gt;pid=345&lt;/Applications&gt;
			&lt;Name&gt;Nox3&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;104&lt;/Action&gt;
			&lt;Applications&gt;pid=936&lt;/Applications&gt;
			&lt;Name&gt;Nox4&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;105&lt;/Action&gt;
			&lt;Applications&gt;pid=54734&lt;/Applications&gt;
			&lt;Name&gt;Nox5&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;106&lt;/Action&gt;
			&lt;Applications&gt;pid=6435&lt;/Applications&gt;
			&lt;Name&gt;Nox6&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;107&lt;/Action&gt;
			&lt;Applications&gt;pid=95325&lt;/Applications&gt;
			&lt;Name&gt;Nox7&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;108&lt;/Action&gt;
			&lt;Applications&gt;pid=10&lt;/Applications&gt;
			&lt;Name&gt;Nox8&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;109&lt;/Action&gt;
			&lt;Applications&gt;pid=000992&lt;/Applications&gt;
			&lt;Name&gt;Nox9&lt;/Name&gt;
		&lt;/Rule&gt;
	&lt;/RuleList&gt;
=====
4323
12
87654
345
936
54734
6435
95325
10
000992
=====
45415
7684
124
6845
3210
16
785
8651
245
8521
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Now, place the caret right before the <strong>first</strong> number of your list ( <strong><code>45415</code></strong>)</p>
</li>
<li>
<p dir="auto">Do a <strong>rectangular</strong> selection ( <strong><code>10 × 5</code></strong> ), taking <strong>all</strong> your list of numbers</p>
</li>
<li>
<p dir="auto">Hit the <strong><code>Ctrl + C</code></strong> shortcut</p>
</li>
<li>
<p dir="auto">Move <strong>backward</strong> and place the caret right after the <strong>first</strong> present number ( <strong><code>4323</code></strong> )</p>
</li>
<li>
<p dir="auto">Add <strong><code>4</code></strong> <strong>space</strong> characters</p>
</li>
<li>
<p dir="auto">Hit the <strong><code>Ctrl + V</code></strong> shortcut</p>
</li>
</ul>
<p dir="auto">Now, our text becomes :</p>
<pre><code class="language-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
	&lt;RuleList&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;100&lt;/Action&gt;
			&lt;Applications&gt;pid=4323&lt;/Applications&gt;
			&lt;Name&gt;Nox0&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;101&lt;/Action&gt;
			&lt;Applications&gt;pid=12&lt;/Applications&gt;
			&lt;Name&gt;Nox1&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;102&lt;/Action&gt;
			&lt;Applications&gt;pid=87654&lt;/Applications&gt;
			&lt;Name&gt;Nox2&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;103&lt;/Action&gt;
			&lt;Applications&gt;pid=345&lt;/Applications&gt;
			&lt;Name&gt;Nox3&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;104&lt;/Action&gt;
			&lt;Applications&gt;pid=936&lt;/Applications&gt;
			&lt;Name&gt;Nox4&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;105&lt;/Action&gt;
			&lt;Applications&gt;pid=54734&lt;/Applications&gt;
			&lt;Name&gt;Nox5&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;106&lt;/Action&gt;
			&lt;Applications&gt;pid=6435&lt;/Applications&gt;
			&lt;Name&gt;Nox6&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;107&lt;/Action&gt;
			&lt;Applications&gt;pid=95325&lt;/Applications&gt;
			&lt;Name&gt;Nox7&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;108&lt;/Action&gt;
			&lt;Applications&gt;pid=10&lt;/Applications&gt;
			&lt;Name&gt;Nox8&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;109&lt;/Action&gt;
			&lt;Applications&gt;pid=000992&lt;/Applications&gt;
			&lt;Name&gt;Nox9&lt;/Name&gt;
		&lt;/Rule&gt;
	&lt;/RuleList&gt;
=====
4323    45415
12      7684
87654   124
345     6845
936     3210
54734   16
6435    785
95325   8651
10      245
000992  8521
=====
45415
7684
124
6845
3210
16
785
8651
245
8521
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Open the <strong>Replace</strong> diialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?s)pid=(\d+)(?=&lt;)(?=.+?^\1\x20+(\d+)$)|^=====.+</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>?1pid=\2</code></strong></p>
</li>
<li>
<p dir="auto">Untick <strong>All</strong> options</p>
</li>
<li>
<p dir="auto"><strong>Tick</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click <strong>once</strong> only on the <strong><code>Replace All</code></strong> button ( or <strong>several</strong> times on the <strong><code>Replace</code></strong> button till the <strong>end</strong> of the process ! )</p>
</li>
</ul>
<p dir="auto">And you’re left with the <strong>expected</strong> results ;-))</p>
<pre><code class="language-xml">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
	&lt;RuleList&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;100&lt;/Action&gt;
			&lt;Applications&gt;pid=45415&lt;/Applications&gt;
			&lt;Name&gt;Nox0&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;101&lt;/Action&gt;
			&lt;Applications&gt;pid=7684&lt;/Applications&gt;
			&lt;Name&gt;Nox1&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;102&lt;/Action&gt;
			&lt;Applications&gt;pid=124&lt;/Applications&gt;
			&lt;Name&gt;Nox2&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;103&lt;/Action&gt;
			&lt;Applications&gt;pid=6845&lt;/Applications&gt;
			&lt;Name&gt;Nox3&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;104&lt;/Action&gt;
			&lt;Applications&gt;pid=3210&lt;/Applications&gt;
			&lt;Name&gt;Nox4&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;105&lt;/Action&gt;
			&lt;Applications&gt;pid=16&lt;/Applications&gt;
			&lt;Name&gt;Nox5&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;106&lt;/Action&gt;
			&lt;Applications&gt;pid=785&lt;/Applications&gt;
			&lt;Name&gt;Nox6&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;107&lt;/Action&gt;
			&lt;Applications&gt;pid=8651&lt;/Applications&gt;
			&lt;Name&gt;Nox7&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;108&lt;/Action&gt;
			&lt;Applications&gt;pid=245&lt;/Applications&gt;
			&lt;Name&gt;Nox8&lt;/Name&gt;
		&lt;/Rule&gt;
		&lt;Rule enabled="true"&gt;
			&lt;Action type="Proxy"&gt;109&lt;/Action&gt;
			&lt;Applications&gt;pid=8521&lt;/Applications&gt;
			&lt;Name&gt;Nox9&lt;/Name&gt;
		&lt;/Rule&gt;
	&lt;/RuleList&gt;
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73820</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73820</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 07 Feb 2022 21:19:54 GMT</pubDate></item></channel></rss>