<?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[Find a text in multiline and replace text]]></title><description><![CDATA[<p dir="auto">I would like to find a block of text which can be multi-line or single line.</p>
<ol>
<li>It will start with find first</li>
<li>it will end with dot/period.</li>
<li>Would like to replace “find first” with " for first "</li>
<li>period should be replaced with " : end . "</li>
<li>if there is any no-error within the text it should get removed.</li>
</ol>
<p dir="auto">Example 1.</p>
<p dir="auto">find first customer    no-lock    where custnum = “Number1”    no-error.<br />
output should be<br />
For first customer    no-lock    where custnum = “Number1”  :  END .</p>
<p dir="auto">Example 2<br />
find first customer   no-lock<br />
where custnum = “Number1”<br />
and Col1 = Val1<br />
and col2 = val2<br />
and col3 = val3<br />
no-error.<br />
output should be<br />
For first customer   no-lock<br />
where custnum = “Number1”<br />
and Col1 = Val1<br />
and col2 = val2<br />
and col3 = val3<br />
: END.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21559/find-a-text-in-multiline-and-replace-text</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 20:24:09 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21559.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Jul 2021 19:03:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 18:42:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/shashi-bhosale" aria-label="Profile: shashi-bhosale">@<bdi>shashi-bhosale</bdi></a> said in <a href="/post/68537">Find a text in multiline and replace text</a>:</p>
<blockquote>
<p dir="auto">Thanks a lot for help. What website you use to get explanation of the command ?</p>
</blockquote>
<p dir="auto">You could look in this forum’s <a href="/category/7/faq">FAQ section</a> and find the FAQ entry about <a href="/topic/15765">Where to find regular expression documentation</a>.  It links to the official Notepad++ regular expression documentation, as well as several external sites which are useful for learning about or experimenting with or describing the specifics of regular expressions.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68538</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68538</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 03 Aug 2021 18:42:15 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 18:37:57 GMT]]></title><description><![CDATA[<p dir="auto">Thanks a lot for help. What website you use to get explanation of the command ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68537</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68537</guid><dc:creator><![CDATA[shashi bhosale]]></dc:creator><pubDate>Tue, 03 Aug 2021 18:37:57 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 18:26:43 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shashi-bhosale" aria-label="Profile: shashi-bhosale">@<bdi>shashi-bhosale</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">OK. So the <strong>new</strong> S/R is, simply :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?si)find\x20+(first\x20(?:phila|oshk).+?)no-error\x20*\.\x20*$</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>For\x20\1:\x20END.</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">I’ve just changed the part <strong><code>(first.+?)</code></strong>, which represents the <strong>group <code>1</code></strong>, by the syntax <strong><code>(first\x20(?:phila|oshk).+?)</code></strong></p>
</li>
<li>
<p dir="auto">As you can see, *<strong>after</strong> the string <strong><code>first</code></strong>, whatever its case, I <strong>inserted</strong> the regex <strong><code>\x20(?:phila|oshk)</code></strong> containing, after the <strong>space</strong> char, a <strong><code>(?:••••••••)</code></strong> structure, known as a <strong>non-capturing</strong> group.</p>
</li>
<li>
<p dir="auto">Inside this <strong>non-capturing</strong> group, it looks, <strong>either</strong>, for the string <strong><code>phila</code></strong> <em>OR</em> the string <strong><code>oshk</code></strong>, due to the <strong>alternation</strong> symbol <strong><code>|</code></strong></p>
</li>
<li>
<p dir="auto">Note that you may <strong>extend</strong> this list of <strong>alternatives</strong>, for instance, with the regex <strong><code>(?:phila|oshk|third_case|fourth_case|fifth_case...)</code></strong></p>
</li>
</ul>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68536</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68536</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 03 Aug 2021 18:26:43 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 11:53:01 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> said in <a href="/post/68427">Find a text in multiline and replace text</a>:</p>
<blockquote>
<p dir="auto">For\x20\1:\x20END.</p>
</blockquote>
<p dir="auto">Thanks. This is great. Works fine.<br />
I would like to change this to a choice values.</p>
<p dir="auto">Find first phila.employee no-lock no-error.<br />
Find first oshk.employee no-lock no-error.<br />
Find first Germany.employee no-lock no-error.</p>
<p dir="auto">The search should find phila and oshk but ignore anything which is not Phila or Oshk.<br />
it should find first 2 lines and ignore 3rd line.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68527</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68527</guid><dc:creator><![CDATA[shashi bhosale]]></dc:creator><pubDate>Tue, 03 Aug 2021 11:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 18:25:44 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shashi-bhosale" aria-label="Profile: shashi-bhosale">@<bdi>shashi-bhosale</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Sorry for my <strong>late</strong> reply :-((</p>
<p dir="auto">So, for instance given this <em>INPUT</em> text :</p>
<pre><code class="language-diff">  find         first ki.timeatt no-LOCK WHERE
  ki.TimeAtt.emp-num = ki.pcn.emp-num AND
  ki.TimeAtt.typecode = ki.pcn.typecode AND
  ki.TimeAtt.cdate = LvPCNDate NO-ERROR   .


find first
ki.timeatt no-LOCK
WHERE
ki.TimeAtt.emp-num = ki.pcn.emp-num AND
ki.TimeAtt.typecode = ki.pcn.typecode AND
ki.TimeAtt.cdate = LvPCNDate
NO-ERROR. 
</code></pre>
<p dir="auto">The <strong>regex</strong> S/R, below :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?si)find\x20+(first.+?)no-error\x20*\.\x20*$</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>For\x20\1:\x20END.</code></strong></p>
</li>
</ul>
<p dir="auto">should give the <strong>expected</strong> <em>OUTPUT</em> text :</p>
<pre><code class="language-diff">  For first ki.timeatt no-LOCK WHERE
  ki.TimeAtt.emp-num = ki.pcn.emp-num AND
  ki.TimeAtt.typecode = ki.pcn.typecode AND
  ki.TimeAtt.cdate = LvPCNDate : END.


For first
ki.timeatt no-LOCK
WHERE
ki.TimeAtt.emp-num = ki.pcn.emp-num AND
ki.TimeAtt.typecode = ki.pcn.typecode AND
ki.TimeAtt.cdate = LvPCNDate
: END.
</code></pre>
<hr />
<p dir="auto">As you can see, I changed and <strong>simplified</strong> the global <strong>logic</strong> of the S/R :</p>
<ul>
<li>
<p dir="auto">The words/string <strong><code>find</code></strong>, <strong><code>first</code></strong> and <strong><code>no-error</code></strong> are searched <strong>whatever</strong> their <strong>case</strong>, due to the <strong>initial</strong> syntax <strong><code>(?i)</code></strong>. So, for instance, the words <strong><code>Find</code></strong>, <strong><code>fIRsT</code></strong> and <strong><code>no-ERRORS</code></strong> will be <strong>matched</strong> !</p>
</li>
<li>
<p dir="auto">The <strong><code>\x20+</code></strong> syntax, between the two words <strong><code>find</code></strong> and <strong><code>first</code></strong>, represents any <strong>non-null</strong> range of <strong>space</strong> characters</p>
</li>
<li>
<p dir="auto">The <strong><code>(first.+?)</code></strong> searches the <strong>smallest</strong> range of chars, beginning from word <strong>first</strong>, whatever its <strong>case</strong>, till the <strong>next</strong> string <strong><code>no-error</code></strong>, <strong>excluded</strong> and is stored as <strong>group<code>1</code></strong>, due to the <strong>parentheses</strong></p>
</li>
<li>
<p dir="auto">Then, the part <strong><code>no-error\x20*</code></strong> looks for the string <strong><code>no-error</code></strong>, whatever its <strong>case</strong>, followed with an <strong>optional</strong> range of <strong>space</strong> characters</p>
</li>
<li>
<p dir="auto">and the <strong>final</strong> part <strong><code>\.\x20$*</code></strong> searches for a <strong>literal</strong> dot char followed by <strong>optional space</strong> characters again, ending the <strong>current</strong> line</p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong> :</p>
<ul>
<li>
<p dir="auto">The part <strong><code>For\x20</code></strong> replaces the word <strong><code>find</code></strong> followed with <strong>space</strong> char(s) by the word <strong>For</strong>, followed with a single <strong>space</strong> char</p>
</li>
<li>
<p dir="auto">Then, the <strong>group <code>1</code></strong> is rewritten ( <strong><code>\1</code></strong> )</p>
</li>
<li>
<p dir="auto">Finally, the part <strong><code>:\x20END.</code></strong> replaces the string <strong><code>no-error</code></strong> with <strong>optional space</strong> chars and a <strong>final</strong> <strong><code>.</code></strong> char by the string <strong><code>: END.</code></strong> with this <strong>exact</strong> case</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Cheers</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68427</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68427</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 03 Aug 2021 18:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Wed, 28 Jul 2021 18:40:25 GMT]]></title><description><![CDATA[<p dir="auto">Nothing in the whole block is case sensitive. Also i string could look like below too.<br />
find first<br />
ki.timeatt no-LOCK<br />
WHERE<br />
ki.TimeAtt.emp-num = ki.pcn.emp-num AND<br />
ki.TimeAtt.typecode = ki.pcn.typecode AND<br />
ki.TimeAtt.cdate = LvPCNDate<br />
NO-ERROR     .</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68409</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68409</guid><dc:creator><![CDATA[shashi bhosale]]></dc:creator><pubDate>Wed, 28 Jul 2021 18:40:25 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Wed, 28 Jul 2021 11:45:47 GMT]]></title><description><![CDATA[<p dir="auto">good except if there is spaces after no-error it doesnt work .</p>
<pre><code>  find first ki.timeatt no-LOCK WHERE
  ki.TimeAtt.emp-num = ki.pcn.emp-num AND
  ki.TimeAtt.typecode = ki.pcn.typecode AND
  ki.TimeAtt.cdate = LvPCNDate NO-ERROR   .
</code></pre>
<p dir="auto">I want to ignore spaces or black new line and eliminate NO-ERROR .</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68393</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68393</guid><dc:creator><![CDATA[shashi bhosale]]></dc:creator><pubDate>Wed, 28 Jul 2021 11:45:47 GMT</pubDate></item><item><title><![CDATA[Reply to Find a text in multiline and replace text on Tue, 03 Aug 2021 18:28:01 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/shashi-bhosale" aria-label="Profile: shashi-bhosale">@<bdi>shashi-bhosale</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Very easy with <strong>regexes</strong> !</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>(?s-i)find (?=first)(.+?)(?:no-error)?(?=\.$)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>For \1: END</code></strong></p>
</li>
<li>
<p dir="auto">Tick, preferably, 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> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Voila !</p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">First, the part <strong><code>(?s-i)</code></strong> ensures that :</p>
<ul>
<li>
<p dir="auto">The <strong>dot</strong> regex char ( <strong><code>.</code></strong> ) matches <strong>any</strong> character, even <strong>EOL</strong> ones ( <strong><code>\r</code></strong> and <strong><code>\n</code></strong> ), due to the <strong><code>(?s)</code></strong> syntax</p>
</li>
<li>
<p dir="auto">The search is processed in a <strong>sensitive</strong> way ( <strong>non-insensitive</strong> way ), due the the <strong><code>(?-i)</code></strong> syntax</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Then, the part <strong><code>find (?=first)</code></strong> searches for the <strong><code>find</code></strong> string, with this <strong>exact</strong> case, followed with a <strong>space</strong> char</p>
</li>
<li>
<p dir="auto">But, <em>ONLY IF</em> it is followed with the <strong><code>first</code></strong> string, with this <strong>exact</strong> case, due to the <strong>look-ahead</strong> structure <strong><code>(?=first)</code></strong></p>
</li>
<li>
<p dir="auto">Then the <strong>middle</strong> part <strong><code>(.+?)</code></strong> matches the <strong>smallest</strong> <em>non-null</em> <strong>multi-lines</strong> range of <strong>any</strong> character, from after the string <strong><code>find</code></strong> and the <strong>space</strong> char, stored as <strong>group <code>1</code></strong>, due to <strong>parentheses</strong>, till…</p>
</li>
<li>
<p dir="auto">… An <strong>optional</strong> string <strong><code>no-error</code></strong>, with this <strong>exact</strong> case, stored in a <strong>non-capturing</strong> group and <em>ONLY IF</em> it is followed with an <strong>literal period</strong> char, <strong>ending</strong> the current line, due to the <strong>final</strong> syntax <strong><code>(?:no-error)?(?=\.$)</code></strong></p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, we rewrite :</p>
<ul>
<li>
<p dir="auto">First the string <strong>For</strong>, followed with a <strong>space</strong> char</p>
</li>
<li>
<p dir="auto">Then, the contents of <strong>group <code>1</code></strong> ( <strong><code>\1</code></strong> )</p>
</li>
<li>
<p dir="auto">Finally, the <strong>literal</strong> string <strong><code>: END</code></strong>, with this <strong>exact</strong> case !</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68354</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68354</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 03 Aug 2021 18:28:01 GMT</pubDate></item></channel></rss>