<?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[Join&#x2F;Merge two lines on condition]]></title><description><![CDATA[<p dir="auto">HI all.  A data file has “name” and “numb” lines sequentially.<br />
Is there a way to combine the name/numb into one line?<br />
And as you see in the example below, “sam” does not have<br />
a “numb” line, so that one would have to be skipped over.<br />
Any thoughts?  I’ve been at this for a while (:</p>
<p dir="auto">name=john<br />
numb=053a82bf31d0f63e669e9035bea4f311<br />
name=pete<br />
numb=a0c49c5e34724c1247b314a3647c3acb<br />
name=sam<br />
name=eric<br />
numb=e368627d9bd60c6e38349532d966df4e<br />
name=steve<br />
numb=b03438713f2894d97f139721f98b2794</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16991/join-merge-two-lines-on-condition</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 03:58:35 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16991.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Jan 2019 00:26:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Join&#x2F;Merge two lines on condition on Wed, 23 Jan 2019 14:44:02 GMT]]></title><description><![CDATA[<p dir="auto">If you used the capital <code>\R</code> in my regex above, it should have worked, whether your file had CRLF (windows, aka <code>\r\n</code>) or LF (linux and modern mac, <code>\n</code>), or CR (old macos <code>\r</code>).    It should have worked even if some were CRLF and some were LF.  It wouldn’t work, however, if there was a blank line between, or other such oddity.</p>
<p dir="auto">If you open the original file in Notepad++, and enable <strong>View &gt; Show Symbol &gt; Show All Characters</strong>, you should see little black boxes for the end of line, either two with <code>CR</code> and <code>LF</code>, or one or the other… Plus, your status bar should list what EOL Notepad++ detects (<code>Windows (CR LF)</code>, <code>Unix (LF)</code>, or <code>Macintosh (CR)</code>).  If you give us a screenshot (see the <a href="https://notepad-plus-plus.org/community/topic/14262/how-to-markdown-code-on-this-forum/2" rel="nofollow ugc">help-with-markdown</a> post for screenshot help; use the <code>![](url.to/image.png)</code>-notation so the image is visible in the forum), we might be able to see why the regex didn’t work in your original file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/38814</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38814</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 23 Jan 2019 14:44:02 GMT</pubDate></item><item><title><![CDATA[Reply to Join&#x2F;Merge two lines on condition on Wed, 23 Jan 2019 05:25:31 GMT]]></title><description><![CDATA[<p dir="auto">As it turns out, my file was somewhat incompatible.<br />
For another test, I created a new file from within Notepad++,<br />
added a few lines, and your code worked flawlessly.<br />
Probably some bad CR or LF perhaps in my org. file?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/38792</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38792</guid><dc:creator><![CDATA[Frozen Biker]]></dc:creator><pubDate>Wed, 23 Jan 2019 05:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to Join&#x2F;Merge two lines on condition on Wed, 23 Jan 2019 02:36:56 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for posting that code, and for the summary of how it works.<br />
Sadly tho, I get the “Find: Can’t find the text” error.<br />
I don’t think the \r or \n works for me in any capacity here; always see that error.</p>
<p dir="auto">To rule out the possibility that the data file (.xml) is corrupt, I copied a few<br />
lines (one by one) to the plain (windows) text file, and then had Notepad++<br />
load that one, but saw the same error…</p>
<p dir="auto">I’m on Windows 10 with Notepad++ v7.6.2 in case this matters.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/38790</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38790</guid><dc:creator><![CDATA[Frozen Biker]]></dc:creator><pubDate>Wed, 23 Jan 2019 02:36:56 GMT</pubDate></item><item><title><![CDATA[Reply to Join&#x2F;Merge two lines on condition on Wed, 23 Jan 2019 01:12:15 GMT]]></title><description><![CDATA[<p dir="auto">You can do it using regular expressions in hte search/replace.</p>
<pre><code class="language-z">name=john
numb=053a82bf31d0f63e669e9035bea4f311
name=pete
numb=a0c49c5e34724c1247b314a3647c3acb
name=sam
name=eric
numb=e368627d9bd60c6e38349532d966df4e
name=steve
numb=b03438713f2894d97f139721f98b2794
</code></pre>
<ul>
<li>
<p dir="auto">Find What = <code>(?-s)(name=.*)\R(numb=.*)$</code></p>
</li>
<li>
<p dir="auto">Replace With = <code>$1 : $2</code></p>
</li>
<li>
<p dir="auto">Mode = Regular Expression</p>
</li>
<li>
<p dir="auto">the first term tells it to have <code>.</code> not match EOL characters</p>
</li>
<li>
<p dir="auto">the second puts the <code>name=somethingerother</code> line into <code>$1</code></p>
</li>
<li>
<p dir="auto">the <code>\R</code> eats a newline (EOL) sequence</p>
</li>
<li>
<p dir="auto">the final parenthetical stores the <code>numb=...</code> into <code>$2</code></p>
</li>
<li>
<p dir="auto">the <code>$</code> says it must grab until the end-of-line</p>
</li>
</ul>
<p dir="auto">in the replace, it’s just the two stored values, separated by a literal space, colon, space.  (You wanted ideas, and didn’t specify a separator)</p>
<p dir="auto">result =</p>
<pre><code class="language-z">name=john : numb=053a82bf31d0f63e669e9035bea4f311
name=pete : numb=a0c49c5e34724c1247b314a3647c3acb
name=sam
name=eric : numb=e368627d9bd60c6e38349532d966df4e
name=steve : numb=b03438713f2894d97f139721f98b2794
</code></pre>
<p dir="auto">-----</p>
<blockquote>
<p dir="auto">FYI: if you have further regex needs, study <a href="https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation" rel="nofollow ugc">this FAQ</a> and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting the data so that the forum doesn’t mangle it (so that it shows “exactly”, as I said earlier), see <a href="https://notepad-plus-plus.org/community/topic/14262/how-to-markdown-code-on-this-forum/2" rel="nofollow ugc">this help-with-markdown post</a>, where <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@Scott-Sumner</a> gives a great summary of how to use Markdown for this forum’s needs.<br />
Please note that for all “regex” queries – or queries where you want help “matching” or “marking” or “bookmarking” a certain pattern, which amounts to the same thing – it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/38787</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38787</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 23 Jan 2019 01:12:15 GMT</pubDate></item></channel></rss>