<?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[Add new lines after matching lines (was:'Hello ALL')]]></title><description><![CDATA[<p dir="auto">I want to search some variable data that I can do but I have to and new line keeping Old search value remain same.<br />
e.g.  -<br />
set @queryName =  ‘XXXX’            –  Where XXXX is variable<br />
New replaced value should be  -  like below string</p>
<p dir="auto">set @queryName =  ‘XXXX’<br />
IF X =  Y  Then (I have to add new line followed by search string)</p>
<p dir="auto">Thanks in  advance</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18963/add-new-lines-after-matching-lines-was-hello-all</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 20:15:45 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18963.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Feb 2020 10:43:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Tue, 25 Feb 2020 16:10:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/50922">Add new lines after matching lines (was:'Hello ALL')</a>:</p>
<blockquote>
<p dir="auto">(?-s)set @queryName = '(.<em>)';\h</em>(?:(\R)|\z)\K</p>
</blockquote>
<p dir="auto">Hi PeterJones  – Thanks a lot for your valuable time, your solution working successfully, I am new here but it’s quite interesting to learn regex.</p>
<p dir="auto">:) Thanks you Sir</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50943</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50943</guid><dc:creator><![CDATA[Rajeev Gupta]]></dc:creator><pubDate>Tue, 25 Feb 2020 16:10:03 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 15:28:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rajeev-gupta" aria-label="Profile: Rajeev-Gupta">@<bdi>Rajeev-Gupta</bdi></a> ,</p>
<blockquote>
<p dir="auto">Hope now its very clear to you</p>
</blockquote>
<p dir="auto">You apparently didn’t read in my boilerplate where I explained how to mark the data as code using the <code>&lt;/&gt;</code> button that’s on the toolbar when you are writing your post. It makes it much easier to know for sure what your data is without the forum mangling characters, and to distinguish your narrative from your data.  Please use that.</p>
<p dir="auto">Further, though you used more words to explain, what you didn’t do is say whether one or both of our solutions works for you.</p>
<p dir="auto">Also, that semicolon is new information, which changes the regex.  If you want helpful answers, you need to give us representative examples of your data, or you are going to have to be willing to edit the regex to meet your needs.  And if you ask more questions, you will have to tell us what didn’t work for you (ie, did it not match anything?  or did it match something, but not give the exact replacement you expected? or …)</p>
<p dir="auto">Please help us help you by formatting the text as has been requested, and giving us example before and after data, without changing the expectations every post.</p>
<p dir="auto">If I modify <a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a>’s expression to include the semicolon and to use your more-specific replacement example:</p>
<ul>
<li>find = <code>(?-s)(set @queryName = '.+';\h*\R)</code> – I added <code>(?-s)</code> to enforce <code>.</code>-does-not-match-newline, and added the semicolon that you didn’t tell us about.</li>
<li>replace = <code>$1if @DebugMode &gt; 1\r\nBEGIN\r\n********\r\nEND\r\n</code> – I changed the IF statement, and included BEGIN/END wrappers</li>
</ul>
<p dir="auto">It turned the document:</p>
<pre><code>set @queryName = 'InsertCNameforLessThan15';
blah
blah

set @queryName = 'InsertCNameforLessThan20';
halb
halb
</code></pre>
<p dir="auto">into</p>
<pre><code>set @queryName = 'InsertCNameforLessThan15';
if @DebugMode &gt; 1
BEGIN
********
END
blah
blah

set @queryName = 'InsertCNameforLessThan20';
if @DebugMode &gt; 1
BEGIN
********
END
halb
halb
</code></pre>
<p dir="auto">Please notice how using the <code>&lt;/&gt;</code> button has put the text into a plaintext box, and the ASCII quotes <code>'...'</code> do not get turned into smartquotes <code>‘...’</code>, so it’s a more-accurate representation of your data.</p>
<p dir="auto">Using Eko’s  as the base, I was able to generate something that I think meets your expectations, assuming that <code>****</code> isn’t supposed to include anything from the original match.</p>
<p dir="auto">Using mine as the base,</p>
<ul>
<li>find = <code>(?-s)set @queryName = '(.*)';\h*(?:(\R)|\z)\K</code></li>
<li>replace = <code>(?2:\r\n)if @DebugMode &gt; 1\r\nBEGIN\r\n***** this allows your replacement to embed the matching string from the match =  '$1' *****\r\nEND\r\n</code></li>
</ul>
<p dir="auto">(if we haven’t made it clear in our answers, all of these answers assume <strong>☑ regular expression</strong> is enabled)</p>
<p dir="auto">For my regex, modified for semicolon <code>;</code> and your more-specific replacement, the <code>***</code> will be able to include the text from inside your queryName string, so</p>
<pre><code>set @queryName = 'InsertCNameforLessThan15';
blah
blah

set @queryName = 'InsertCNameforLessThan20';
</code></pre>
<p dir="auto">which has the last line end with no newline character, will become</p>
<pre><code>set @queryName = 'InsertCNameforLessThan15';
if @DebugMode &gt; 1
BEGIN
***** this allows your replacement to embed the matching string from the match =  'InsertCNameforLessThan15' *****
END
blah
blah

set @queryName = 'InsertCNameforLessThan20';
if @DebugMode &gt; 1
BEGIN
***** this allows your replacement to embed the matching string from the match =  'InsertCNameforLessThan20' *****
END
</code></pre>
<p dir="auto">Both of these meet your expressed needs, and you should have been able to figure out how to put the semicolon after the closing <code>'</code> to make it match for you.</p>
<p dir="auto">At this point, I am done with freebies for you.  If you show more effort – properly formatting your post so the data comes through, giving us representative data, telling us whether or not ours work, and what isn’t right (for example, saying “when I tried it with data <code>xyz</code>, your expression made it <code>pdq</code>, but I wanted <code>pdqu</code>; I tried modifying the regex to <code>rr;r</code>, because I thought adding the semicolon would make it match more accurately, but that made it say <code>pdqv</code>, which still isn’t quite what I wanted”) – if you show that level of effort, so that we can tell you’re trying to learn from us rather than mooch off us, then I’ll be willing to answer more well-formed questions about this regex.  If you don’t, well, we’ve given enough that assuming your data was correct, it will work for you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50922</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50922</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 24 Feb 2020 15:28:53 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:59:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> Thanks for reply –  Its typo mistake -  Extremply sorry for that</p>
<p dir="auto">I will explain in detail -  I have multiple files around 400 where I have to Add new line code for example</p>
<p dir="auto">In one file it is -   set @queryName = ‘InsertCNameforLessThan15’;<br />
and other file it   set @queryName = ‘InsertCNameforLessThan20’;<br />
any other file  set @queryName = ‘Table Update’;</p>
<p dir="auto">So  set @queryName = ‘Table Update’;<br />
this value is dynamic<br />
I dont want to change anything in this string I have to add some code after this line</p>
<p dir="auto">like -  1  –  set @queryName = ‘InsertCNameforLessThan15’;<br />
if @DebugMode &gt; 1<br />
begin<br />
********************<br />
END</p>
<p dir="auto">similer for others<br />
set @queryName = ‘InsertCNameforLessThan20’;<br />
if @DebugMode &gt; 1<br />
begin<br />
*********<br />
END</p>
<p dir="auto">Hope now its very clear to you - -</p>
<p dir="auto">Thanks<br />
And again sorry for wrongly word.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50921</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50921</guid><dc:creator><![CDATA[Rajeev Gupta]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:55:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">It turns the entire match into a zero-length assertion.  But, it is worth pointing out that it only works if you are doing a “Replace All” and not an interactive “FindNext-then-Replace”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50920</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50920</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:55:46 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:38:43 GMT]]></title><description><![CDATA[<p dir="auto">I picked up the <code>\K</code>-for-add-after-match idiom from <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> and/or <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> somewhere along the way, and it’s started to stick to my regexes.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50919</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50919</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Tue, 25 Feb 2020 02:48:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/50916">Hello ALL,</a>:</p>
<blockquote>
<p dir="auto">It resets the match, so that I didn’t have to include an $1 at the beginning to replace the originally-matched line with itself.<br />
(match) -&gt; $1NEW is equivalent to (match)\K -&gt; NEW – both will just append NEW after the original match.</p>
</blockquote>
<p dir="auto">Ah, nice one.  I don’t think I’ve seen that usage of <code>\K</code> before.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50917</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50917</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 25 Feb 2020 02:48:13 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:32:02 GMT]]></title><description><![CDATA[<p dir="auto">It resets the match, so that I didn’t have to include an $1 at the beginning to replace the originally-matched line with itself.</p>
<p dir="auto"><code>(match)</code> -&gt; <code>$1NEW</code> is equivalent to <code>(match)\K</code> -&gt; <code>NEW</code> – both will just append NEW after the original match.</p>
<p dir="auto">Thanks for prompting me to explain that better.</p>
<p dir="auto">Also, since the OP hasn’t seen my boilerplate yet, some advice for <a class="plugin-mentions-user plugin-mentions-a" href="/user/rajeev-gupta" aria-label="Profile: Rajeev-Gupta">@<bdi>Rajeev-Gupta</bdi></a><br />
-----</p>
<h3>Please Read And Understand This</h3>
<p dir="auto">The Notepad++ Community is not a search-and-replace (regex) help forum. However, we are often willing to help with regex questions as they pertain to Notepad++, assuming you follow a few simple rules.</p>
<ol>
<li>
<p dir="auto">Be polite: ask nicely.  We’re all here voluntarily.</p>
</li>
<li>
<p dir="auto">Be patient: understand that everyone in the Community has their own schedule for when they are and aren’t available to respond: a day or two is not an unreasonable response time.</p>
</li>
<li>
<p dir="auto">Show a willingness to learn: we understand that you might be new to regexes.</p>
<ul>
<li>
<p dir="auto">However, the more times we have given you example regexes, the more we will expect you to show some effort.</p>
</li>
<li>
<p dir="auto">Try to craft your own regex.  If it doesn’t work, show us what you tried; explain <em>why</em> you tried that (it shouldn’t be a random guess); explain how the non-working results are different from your expectations.</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Please read the manual.  We’re likely to be lenient at first, giving a freebie or two.  However, the more times you ask regex questions, the more we will expect that you have read and understood the manuals:</p>
<ul>
<li>
<p dir="auto"><a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">the official Notepad++ searching using regular-expressions docs</a></p>
</li>
<li>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">this forum’s regex FAQ</a></p>
</li>
</ul>
</li>
<li>
<p dir="auto">Help us help you:</p>
<ul>
<li>Format your <em>data</em> using the the <code>&lt;/&gt;</code> button (“code”, aka “literal text”), but leave your normal discussion as normal text (don’t put your whole post in literal-text mode)</li>
</ul>
<p dir="auto"><img src="https://i.imgur.com/KOsSLNe.png" alt="" class=" img-fluid img-markdown" /></p>
<ul>
<li>Be clear about what you want to match; be clear about what you <em>don’t</em> want to match; give examples of each.  What <em>doesn’t</em> match is sometimes more important than what <em>does</em> match in order to formulate a reasonable regex for your needs.</li>
</ul>
</li>
<li>
<p dir="auto">We’re not here to do your work.  We are here to help you use Notepad++ to its fullest.  We expect you to learn from our answers.</p>
</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/post/50916</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50916</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:32:02 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:24:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">What is the significance of the <code>\K</code> at the very end of your find regex?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50914</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50914</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:24:34 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Mon, 24 Feb 2020 14:19:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rajeev-gupta" aria-label="Profile: Rajeev-Gupta">@<bdi>Rajeev-Gupta</bdi></a> :</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekopalypse" aria-label="Profile: Ekopalypse">@<bdi>Ekopalypse</bdi></a> has provided a first level suggestion, and we would need clarification to get a better answer than that.  Though if I had been making my guess, I think you want something like:</p>
<ul>
<li>find = <code>(?-s)set @queryName = '(.*)'\h*(?:(\R)|\z)\K</code></li>
<li>replace = <code>(?2:\r\n)IF X=Y then\r\n    something '$1' different\r\n</code></li>
</ul>
<p dir="auto">compared to Eko’s reply, I understood you to want to grab the <code>XXXX</code> contents and reuse it.  I also made sure that if the final line in the file matched, but didn’t have a newline, it will still do the replacement.  So if your file were exactly two lines long, with no newline at the end of the second line:</p>
<pre><code>set @queryName = 'YYYY'
set @queryName = 'XXXX'
</code></pre>
<p dir="auto">it would become</p>
<pre><code>set @queryName = 'YYYY'
IF X=Y then
    something 'YYYY' different
set @queryName = 'XXXX'
IF X=Y then
    something 'XXXX' different
</code></pre>
<p dir="auto">As an aside: unfortunately, your topic title with the typ of “Hell” instead of “Hello” has significantly changed the tone of your topic title with expected content including fiery condemnation, which I doubt is what you were going for. :-)  Unfortunately, original posters cannot edit the name of their Topic, so we need an admin to step in.  However, if you have a suggestion for a more-meaningful title then “Hello All”, it would be helpful.  Our resident forum admin <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> should be able to re-title it to “Hello All”, or whatever you suggest.   (Actually, my default suggestion would be “Add new lines after matching lines, including some data from the match”.  But really, it should be up to <a class="plugin-mentions-user plugin-mentions-a" href="/user/rajeev-gupta" aria-label="Profile: Rajeev-Gupta">@<bdi>Rajeev-Gupta</bdi></a>)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/50913</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50913</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 24 Feb 2020 14:19:40 GMT</pubDate></item><item><title><![CDATA[Reply to Add new lines after matching lines (was:'Hello ALL') on Tue, 25 Feb 2020 02:46:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rajeev-gupta" aria-label="Profile: Rajeev-Gupta">@<bdi>Rajeev-Gupta</bdi></a> said in <a href="/post/50907">Hello ALL,</a>:</p>
<p dir="auto">I’m not 100% sure I understand your request but from the example<br />
you’ve given this might do it</p>
<p dir="auto">find what:<code>(set @queryName = '.+'\h*\R)</code><br />
repalce with:<code>$1IF X = Y Then</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/50910</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/50910</guid><dc:creator><![CDATA[Ekopalypse]]></dc:creator><pubDate>Tue, 25 Feb 2020 02:46:58 GMT</pubDate></item></channel></rss>