<?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 many lines with conditions]]></title><description><![CDATA[<p dir="auto">Sorry I’m newbie, so hard to say exactly what I want only by some words.</p>
<p dir="auto">I’m using Notepad++ to adjust Crusader Kings 3 save file, and I want to do like below:</p>
<ul>
<li>I have many paragraphs like this:</li>
</ul>
<p dir="auto">{<br />
owner=???<br />
target=18028			<br />
temporary_opinion={<br />
modifier=“love_opinion”<br />
start_date=1069.4.24<br />
expiration_date=1398.1.29<br />
converging={<br />
days=2045<br />
opinion=200.4<br />
}<br />
value=197<br />
}<br />
temporary_opinion={<br />
modifier=“friendliness_opinion”<br />
start_date=1069.4.24<br />
expiration_date=1151.7.3<br />
converging={<br />
days=2045<br />
opinion=100.8<br />
}<br />
value=94<br />
}<br />
}</p>
<ul>
<li>In all paragraphs, 1st line “owner=???” will change, but same 2nd line “target=18028”, every other numbers will change too, so I want to use Replace function to delete all “love opinion”, like this:</li>
</ul>
<p dir="auto">{<br />
owner=???<br />
target=18028			<br />
temporary_opinion={<br />
modifier=“friendliness_opinion”<br />
start_date=1069.4.24<br />
expiration_date=1151.7.3<br />
converging={<br />
days=2045<br />
opinion=100.8<br />
}<br />
value=94<br />
}<br />
}</p>
<p dir="auto">Anyone can help me, pls ? Thanks in advance.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20971/replace-many-lines-with-conditions</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 05:31:02 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20971.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 Apr 2021 09:17:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace many lines with conditions on Fri, 02 Apr 2021 03:24:52 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> so much, I used your method and got exact result I want. Great work !</p>
<p dir="auto">I’m still trying to understand your method to know more about NPP.</p>
<p dir="auto">Thanks again. Have a nice day !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64585</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64585</guid><dc:creator><![CDATA[Trần Hoàng Long]]></dc:creator><pubDate>Fri, 02 Apr 2021 03:24:52 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 23:24:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tr%E1%BA%A7n-ho%C3%A0ng-long" aria-label="Profile: trần-hoàng-long">@<bdi>trần-hoàng-long</bdi></a>,</p>
<p dir="auto">Ah…Phhhffff ! I <strong>finally</strong> found out a method ! It wasn’t that <strong>easy</strong> because your data are a bit <strong>complex</strong> !</p>
<hr />
<ul>
<li>
<p dir="auto">Firstly , a <strong>global</strong> section, begins line with a <strong>space</strong> followed with an <strong>opening</strong> brace <strong><code>{</code></strong> till right before an other  <strong>similar</strong> scheme. As<strong>braces</strong> are used in <strong>many other</strong> locations, we’ll have to delimit these sections more <strong>precisely</strong> !</p>
</li>
<li>
<p dir="auto">Secondly, inside a <strong>global</strong> section, the <strong><code>temporary_opinion</code></strong> sub-region may have <strong>three</strong> different syntaxes :</p>
</li>
</ul>
<pre><code class="language-css">temporary_opinion •••••• { ••••••••••••••••••••••••••••••••••••• }LF   (  2,779 occurrences )
temporary_opinion •••••• { ••••••••• { •••••••••••• } •••••••••• }LF   ( 17,224 occurrences )
temporary_opinion •••••• { ••••• { ••••• } ••••• { ••••• } ••••• }LF   (     78 occurrences )
</code></pre>
<p dir="auto">So we’ll have to <strong>detect</strong> these <strong>three</strong> syntaxes, at the <strong>same</strong> time</p>
<ul>
<li>
<p dir="auto">Thirdly, we must <strong>delete</strong> some <strong><code>temporary_opinion</code></strong> sub-region <em>ONLY</em> in <strong>global</strong> sections which verify these <strong>three</strong> criteria :</p>
<ul>
<li>
<p dir="auto">It must contain the string <strong><code>target=18028</code></strong></p>
</li>
<li>
<p dir="auto">It must contain the <strong><code>temporary_opinion</code></strong> sub-region with <strong>modifier</strong> = <strong><code>"love_opinion"</code></strong></p>
</li>
<li>
<p dir="auto">It must contain the <strong><code>temporary_opinion</code></strong> sub-region with <strong>modifier</strong> = <strong><code>"friendliness_opinion"</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Note that the <strong>first</strong> criterion comes <strong>first</strong>, in a section, but the <strong>two</strong> others occur in <strong>any</strong> order !</p>
<p dir="auto">So we’ll need to <strong>distinguish</strong> these <strong>specific</strong> sections, where the <strong>suppression</strong> process will occur, in a <strong>second</strong> time !</p>
<ul>
<li>Fourthly, in these <strong>specific</strong> sections, we have to <strong>delete</strong> any <strong><code>temporary_opinion</code></strong> sub-region when the <strong>modifier</strong> is different from <strong><code>"love_opinion"</code></strong> <em>and</em> different from <strong><code>"friendliness_opinion"</code></strong>.</li>
</ul>
<p dir="auto">But, as these <strong>other</strong> sub-regions may come <strong>before</strong> and/or <strong>after</strong> the sub-regions with <strong><code>"love_opinion"</code></strong> and <strong><code>"friendliness_opinion"</code></strong>, we’ll have to add a <strong>mark</strong> at the <strong>end</strong> of <strong>general</strong> section, to be sure that <strong>all</strong> the <strong><code>temporary_opinion</code></strong> sub-regions, under <strong><code>target=18028</code></strong>, and different from <strong><code>"love_opinion"</code></strong> and <strong><code>"friendliness_opinion"</code></strong>, will be matched and <strong>deleted</strong></p>
<hr />
<p dir="auto">Okay, let’s go :</p>
<ul>
<li>
<p dir="auto">This <strong>first</strong> S/R changes the <strong>beginning</strong> of any <strong>global</strong> section, using a symbol <strong>not</strong> used yet, in your file ( I chose the <strong><code>¤</code></strong> symbol )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>^\x20\{</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>¤</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; <strong><code>27,709</code></strong> replacements</p>
<p dir="auto">From now on, if we <strong>force</strong> the regex engine to look for characters different from <strong><code>¤</code></strong>, we’ll be <strong>sure</strong> that any match will be a <strong>subset</strong> of a <strong>global</strong> section, only. Moreover, it clearly shows the <strong>beginning</strong> of a <strong>next global</strong> section</p>
<hr />
<p dir="auto">The <strong>second</strong> S/R, below, using the <strong>free-spacing</strong> mode, <strong><code>(?x)</code></strong>, will add a <strong><code>@</code></strong> symbol, in a <strong>new</strong> line, right <strong>before</strong> the <strong>next global</strong> section :</p>
<pre><code class="language-z">(?x)                                           #  FREE-SPACING mode
^ \h+ target= 18028 \R   (?: [^¤\r\n]*\R )*    #  Find the line 'target=18028' and possible range of COMPLETE lines, till ...

#  Find a **`temporary_opinion`** sub-region with string "love_opinion" or "friendliness_opinion"
\h+ temporary_opinion = { \R \h+ modifier= "(?:(love)|friendliness) _opinion" (?: [^¤{}]+ { [^¤{}]+ } ){0,2} [^¤{}]+ } \R

(?: [^¤\r\n]*\R )*                             #  Find possible range of COMPLETE lines, till ...

#  Find a **`temporary_opinion`** sub-region with string "friendliness_opinion" or "love_opinion"
\h+ temporary_opinion = { \R \h+ modifier= "(?(1)friendliness|love) _opinion" (?: [^¤{}]+ { [^¤{}]+ } ){0,2} [^¤{}]+ } \R

[^¤]*                                          #  Find the GREATEST range of chars, DIFFERENT from '¤' ( so ENDING right before a '¤' )
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Select <strong>all</strong> the text above, between <strong><code>(?x)</code></strong> and <strong><code>( so ENDING right before a '¤' )</code></strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">The <strong><code>Search what:</code></strong> zone should contain the <strong>selection</strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>$0@\n</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; <strong><code>1,692</code></strong> replacements</p>
<hr />
<p dir="auto">The <strong>third</strong> S/R, below, in the <strong>free-spacing</strong> mode too, will <strong>delete</strong>, in the specific zones <strong>ending</strong> with a <strong><code>@</code></strong> symbol, any <strong><code>temporary_opinion</code></strong> sub-region with modifier <strong>different</strong> from, <strong>either</strong>, <strong><code>"love_opinion"</code></strong> <em>and</em> <strong><code>"friendliness_opinion"</code></strong> :</p>
<pre><code class="language-z">(?x)              #  The next line finds ANY temporary_opinion sub-region, DIFFERENT from "love_opinion" and "friendliness_opinion",
                  #    WHATEVER the 3 POSSIBLE syntaxes
^ \h+ temporary_opinion = { \R \h+ modifier= (?!"love_opinion") (?!"friendliness_opinion") (?: [^¤{}]+ { [^¤{}]+ } ){0,2} [^¤{}]+ } \R
(?= [^¤]* @ )     #  This line ensures that the SUPPRESSIONS only occur in the specific regions matching the 3 CRITERIA !   
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Select <strong>all</strong> the text above, between <strong><code>(?x)</code></strong> and <strong><code>matching the 3 CRITERIA !</code></strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">The <strong><code>Search what:</code></strong> zone should contain the <strong>selection</strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt;  <strong><code>1,483</code></strong> replacements</p>
<hr />
<p dir="auto">Finally, this <strong>fourth</strong> regex S/R will <strong>delete</strong> all the <strong>temporary</strong> <strong><code>¤</code></strong> and <strong><code>@</code></strong> symbols :</p>
<ul>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>^(¤)|^@\R</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>?1\x20{</code></strong></p>
</li>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; <strong><code>29,401</code></strong> replacements</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">It remains <strong><code>1</code></strong> <strong>global</strong> section, with target <strong>different</strong> from <strong><code>18028</code></strong> :</p>
<pre><code class="language-diff"> {
			owner=30639
			target=15484
			temporary_opinion={
				modifier="friendliness_opinion"
				start_date=1074.3.4
				expiration_date=1082.5.23
				converging={
					days=268
					opinion=10.8
				}
				value=10
			}
			temporary_opinion={
				modifier="love_opinion"
				start_date=1074.3.14
				expiration_date=1098.11.9
				converging={
					days=258
					opinion=15.4
				}
				value=15
			}
			scripted_relations={
				potential_lover={ 0 }
			}
		}
</code></pre>
<p dir="auto">I’ve found it, <strong>empirically</strong>, with the regex :</p>
<p dir="auto"><strong><code>(?x-s)  target=  (?!18028) .+\R (.+\R){1,4}  .+?  "friendliness_opinion"\R  (.+\R){1,9}  .+?  "love_opinion"\R</code></strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/64579</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64579</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 01 Apr 2021 23:24:09 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 18:36:21 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tr%E1%BA%A7n-ho%C3%A0ng-long" aria-label="Profile: trần-hoàng-long">@<bdi>trần-hoàng-long</bdi></a>,</p>
<p dir="auto">In <strong>progress</strong> ! Be patient !</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64570</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64570</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 01 Apr 2021 18:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 15:17:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>,</p>
<p dir="auto">There are some paragraphs which have them all, for example like below:</p>
<p dir="auto">{<br />
owner=…<br />
target=18028<br />
temporary_opinion={<br />
modifier=…<br />
…<br />
}<br />
temporary_opinion={<br />
modifier=…<br />
…<br />
}<br />
temporary_opinion={<br />
modifier=“love_opinion”<br />
…<br />
}<br />
temporary_opinion={<br />
modifier=“friendliness_opinion”<br />
…<br />
}<br />
}<br />
In those paragraphs, I want to delete all “temporary_opinion” graphs which are not “love_opinion” or “friendliness_opinion".</p>
<p dir="auto">If “love opinion” or “friendliness_opinion” stand alone, or not have “target=18028”, so just ignore them.</p>
<p dir="auto">The result should be</p>
<p dir="auto">{<br />
owner=…<br />
target=18028<br />
temporary_opinion={<br />
modifier=“love_opinion”<br />
…<br />
}<br />
temporary_opinion={<br />
modifier=“friendliness_opinion”<br />
…<br />
}<br />
}</p>
<p dir="auto">Thanks so much for your help.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64561</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64561</guid><dc:creator><![CDATA[Trần Hoàng Long]]></dc:creator><pubDate>Thu, 01 Apr 2021 15:17:01 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 13:57:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tr%E1%BA%A7n-ho%C3%A0ng-long" aria-label="Profile: trần-hoàng-long">@<bdi>trần-hoàng-long</bdi></a>,</p>
<p dir="auto"><strong>One</strong> more question :</p>
<ul>
<li>
<p dir="auto">Your file contains <strong><code>20</code></strong> strings “<strong><code>love_opinion</code></strong>”, in <strong>target</strong> blocks different from <strong><code>18028</code></strong></p>
</li>
<li>
<p dir="auto">Your file contains <strong><code>868</code></strong> strings “<strong><code>friendliness_opinion</code></strong>”, in <strong>target</strong> blocks different from <strong><code>18028</code></strong></p>
</li>
</ul>
<p dir="auto">Do you want to <strong>remove</strong> or <strong>keep</strong> these lines ?</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64560</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64560</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 01 Apr 2021 13:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 13:21:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> Tks for your reply.</p>
<p dir="auto">I want to do exactly as 2nd post.</p>
<p dir="auto">In 1st post, I wanted to say in short but maybe it leads to wrong meaning. Sorry about it.</p>
<p dir="auto">You can open my file directly with Notepad++, no need to change to .txt :D</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64554</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64554</guid><dc:creator><![CDATA[Trần Hoàng Long]]></dc:creator><pubDate>Thu, 01 Apr 2021 13:21:43 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 13:16:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tr%E1%BA%A7n-ho%C3%A0ng-long" aria-label="Profile: trần-hoàng-long">@<bdi>trần-hoàng-long</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">OK, I’ve got your <strong>file</strong>, that I simply changed as a <strong><code>.txt</code></strong> file. Nice !</p>
<p dir="auto">Now, it’s still <strong>unclear</strong> ! In your <strong>first</strong> post, you said :</p>
<blockquote>
<p dir="auto">… so I want to use Replace function to delete all “<strong><code>love opinion</code></strong>”</p>
</blockquote>
<p dir="auto">And in your <strong>second</strong> post, you said :</p>
<blockquote>
<p dir="auto">I want to delete all “temporary_opinion” which are <strong>not</strong> “<strong><code>love_opinion</code></strong>” or “<code>**friendliness_opinion</code>**” in those paragraphs.</p>
</blockquote>
<p dir="auto">Once I know what is <strong>exactly</strong> needed, with the <strong>true</strong> file, it should be <strong>easy</strong> to found out a solution;-))</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64552</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64552</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 01 Apr 2021 13:16:12 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 13:11:22 GMT]]></title><description><![CDATA[<p dir="auto">P/S: I’m using Notepad ++ v7.8.8, maybe need to turn on/off some functions to make the search work, but I dont know which functions. So if needed and anyone know, pls tell me (or tell me any good workingNotepad++ version), tks so much.</p>
<p dir="auto">I attach screen picture here<br />
<img src="/assets/uploads/files/1617282679988-notepad-version.jpg" alt="Notepad++ version.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/64551</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64551</guid><dc:creator><![CDATA[Trần Hoàng Long]]></dc:creator><pubDate>Thu, 01 Apr 2021 13:11:22 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 13:02:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> Many many thanks to you.<br />
I used your method but not get the result, and dont know why, so I attached my file here for you to check.<br />
<a href="https://drive.google.com/file/d/1WC4VHudMm2Do3_QV1xmQV1h2gAuWo26v/view?usp=sharing" rel="nofollow ugc">https://drive.google.com/file/d/1WC4VHudMm2Do3_QV1xmQV1h2gAuWo26v/view?usp=sharing</a></p>
<p dir="auto">There are many paragraphs start with “owner=…” and “target=18028”, I want to delete all “temporary_opinion” which are not “love_opinion” or “friendliness_opinion” in those paragraphs.</p>
<p dir="auto">Thanks any help in advance.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64550</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64550</guid><dc:creator><![CDATA[Trần Hoàng Long]]></dc:creator><pubDate>Thu, 01 Apr 2021 13:02:33 GMT</pubDate></item><item><title><![CDATA[Reply to Replace many lines with conditions on Thu, 01 Apr 2021 12:24:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tr%E1%BA%A7n-ho%C3%A0ng-long" aria-label="Profile: trần-hoàng-long">@<bdi>trần-hoàng-long</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">OK, So, here is the <strong>road map</strong> :</p>
<ul>
<li>
<p dir="auto">Open your file in N++</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + F</code></strong> )</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?s-i)^target=18028\R\Ktemporary_opinion=\{.+?"love_opinion".+?(?=^temporary_opinion)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></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>Replace All</code></strong> only ( Do <strong>not</strong> use the <strong><code>Replace</code></strong> button )</p>
</li>
</ul>
<p dir="auto">Et voilà !</p>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">First the <strong>modifiers</strong> <strong><code>(?s-i)</code></strong> means that the <strong>dot</strong> regex symbol, <strong><code>.</code></strong>, will match <strong>any</strong> character and that the search is <strong>sensitive</strong> to case</p>
</li>
<li>
<p dir="auto">Then the part <strong><code>^target=18028\R</code></strong> looks for the <strong>literal</strong> string <strong><code>target=18028</code></strong>, with this <strong>exact</strong> case, at <strong>beginning</strong> of line ( <strong><code>^</code></strong> ) followed with its <strong>EOL</strong> characters ( <strong><code>\R</code></strong> )</p>
</li>
<li>
<p dir="auto">Now the <strong><code>\K</code></strong> assertion <strong>resets</strong> the working position and <strong>cancels</strong> any <strong>previous</strong> match</p>
</li>
<li>
<p dir="auto">So, the part <strong><code>temporary_opinion=\{</code></strong> look for the <strong>literal</strong> string <strong><code>temporary_opinion={</code></strong>, with this <strong>exact</strong> case</p>
</li>
<li>
<p dir="auto">Followed with the <strong>smallest</strong> non-null range of <strong>any</strong> char ( <strong><code>.+?</code></strong>) …</p>
</li>
<li>
<p dir="auto">Till the <strong>literal</strong> string <strong><code>"love_opinion"</code></strong>…</p>
</li>
<li>
<p dir="auto">Followed with an other <strong>smallest</strong> non-null range of <strong>any</strong> char (<strong><code>.+?</code></strong>) …</p>
</li>
<li>
<p dir="auto">which <strong>ends</strong> when it’s followed with an other <strong>literal</strong> string <strong><code>temporary_opinion</code></strong> which <strong>begins</strong> a line, due to the <strong>look-ahead</strong> structure <strong><code>(?=^temporary_opinion)</code></strong></p>
</li>
<li>
<p dir="auto">As the <strong>Replacement</strong> zone is <strong>empty</strong>, all this <strong>multi</strong>-lines range of text is then <strong>deleted</strong></p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/64549</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/64549</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 01 Apr 2021 12:24:06 GMT</pubDate></item></channel></rss>