<?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[Remove unwanted Carriage Return]]></title><description><![CDATA[<p dir="auto">Hi, first thank you for your help.</p>
<p dir="auto">I’m reading a chinese novel using translator tool but the text file has unwanted Carriage Return for a long paragraph, it split the paragraph to multiple one. Hope someone can help me solve this problems</p>
<p dir="auto"><img src="https://image.prntscr.com/image/9EmPlhmnSk-4d-AZD2EdHQ.png" alt="alt text" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22430/remove-unwanted-carriage-return</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 17:20:51 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22430.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Jan 2022 05:11:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Mon, 31 Jan 2022 15:29:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> ,</p>
<blockquote>
<p dir="auto">Reading the specs, \d and \R are “peers”,</p>
</blockquote>
<p dir="auto">I disagree.  But I do agree that maybe it could be explained better in the Notepad++ Searching document.  However, that document <em>does</em> point you to the <a href="https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html" rel="nofollow ugc">canonical Boost regex documentation</a>, which is the official spec for the regex used by Notepad++; and, in my opinion, the Boost documents can only be interpreted to say that <code>\R</code> behaves differently than <code>\d</code> or <code>\r</code> or <code>\n</code> or even <code>\h</code> or <code>\v</code> or <code>\s</code>.</p>
<p dir="auto">In that document, you will see that <code>\r</code>, <code>\n</code>, <code>\t</code>, <code>\v</code> and others are listed under the sentence, “The following escape sequences are all synonyms for single characters:” – meaning that each of those sequences matches only a single character at a time.  So <code>\v</code> might match any of the vertical spaces (CR, LF, and the weird ones), but a single <code>\v</code> in a regex will only match a single character at a time.  So if you had the string <code>AB\r\n</code> and matched for <code>\v</code>, the first FIND would find <em>just</em> the <code>\r</code>.</p>
<p dir="auto">The <code>\R</code> is described in its own section called “Matching Line Endings”, which shows that it expands into <code>(?&gt;\x0D\x0A?|[\x0A-\x0C\x85\x{2028}\x{2029}])</code>, which is an expression with parentheses around it and including an internal alternation <code>|</code> – searching for <code>(?&gt;)</code>, you find it’s the syntax for an <a href="https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.independent_sub_expressions" rel="nofollow ugc">independent sub-expression</a> .  This is different than all the single-character escapes listed previously.  With the same string <code>AB\r\n</code>, searching for <code>\R</code>, the first FIND would match the two-character sequence <code>\r\n</code>.  The <code>\R</code> behaves differently than all those other single-character escapes, because it can match multiple characters at once.</p>
<p dir="auto">Then if you back up a few paragraphs to <a href="#boost_regex.syntax.perl_syntax.character_sets">Character sets</a>, you will see the rules for character sets, including the sentence, “A bracket expression may contain any combination of the following:”.  The sub-sections that follow underneath that are “Single characters”, “Character ranges”, “Negation”, “Character classes”, “Collating Elements”, “Collating Elements”, “Equivalence classes”, “Escaped Characters”, and “Combinations”.  Note that none of those include “independent sub-expression”, or any other term that references a parentheses-based expression.</p>
<p dir="auto">The bracket<code>[]</code>-based character sets cannot contain parentheses<code>()</code>-based expressions.  That is why <code>\R</code> does not work in a bracket<code>[]</code>-based class.</p>
<p dir="auto">An updated version of the usermanual mentions of <code>\R</code> can be found at <a href="https://github.com/pryrt/npp-usermanual/blob/backslashBigR/content/docs/searching.md" rel="nofollow ugc">https://github.com/pryrt/npp-usermanual/blob/backslashBigR/content/docs/searching.md</a> (that temporary URL will be changed to the permanent URL by moderator power once the changes are merged into the main usermanual repository)</p>
<ul>
<li>First, it’s been moved out of the <strong>Control Characters</strong> section into its own special section: <img src="/assets/uploads/files/1643639954696-9fe5e730-8a6e-4086-a0bf-07a317ee0e98-image.png" alt="9fe5e730-8a6e-4086-a0bf-07a317ee0e98-image.png" class=" img-fluid img-markdown" /></li>
<li>Second, the <strong>Character Classes</strong> section has been improved to note that character classes cannot contain any parentheses-based group, including <code>\R</code>.  <img src="/assets/uploads/files/1643640020366-667dc9c3-3c5a-4d48-b84f-e1e56ece7d9e-image.png" alt="667dc9c3-3c5a-4d48-b84f-e1e56ece7d9e-image.png" class=" img-fluid img-markdown" /></li>
<li>Third, in the <strong>Character Escape Sequences</strong> section, which contains the <code>\h</code>, <code>\v</code>, and <code>\s</code> (and thus people might assume that <code>\R</code> fits in there), it is clarified that being a group causes <code>\R</code> to be treated differently: <img src="/assets/uploads/files/1643640117825-8cf239b3-bb64-4bdc-ae17-f5735e483916-image.png" alt="8cf239b3-bb64-4bdc-ae17-f5735e483916-image.png" class=" img-fluid img-markdown" /></li>
</ul>
<p dir="auto">Hopefully, this is sufficient description in enough locations that it will prevent future confusion when users are looking up the meaning of <code>\R</code> and whether or not it can go inside a character class.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73518</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73518</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 31 Jan 2022 15:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Mon, 31 Jan 2022 12:49:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a></p>
<p dir="auto">Ok, so I guess you can persist with what you’re talking about, but I suppose you’ll just be talking to yourself. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73514</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73514</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 31 Jan 2022 12:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Mon, 31 Jan 2022 03:00:35 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> said in <a href="/post/73441">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">Everything inside […] is “one character”.</p>
</blockquote>
<p dir="auto">You are backfilling into the spec(s) from observation a concept that isn’t there, even though observation indeed suggests that’s a plausible description of the internals.</p>
<p dir="auto">Reading the specs, \d and \R are “peers”, and behave thusly in other contexts, such as \d+ and \R+, and, (?=\d) and (?=\R).</p>
<blockquote>
<p dir="auto">Easy enough to do [\r\n] anyway, right?</p>
</blockquote>
<p dir="auto">There’s the loss of generality/abstraction. The specs themselves suggest we expect to encounter <code>\x85|\x{2028}|\x{2029}</code> line endings now and again.</p>
<p dir="auto">If 0.5% of people seeking regex help had files in those formats, an experienced person such as yourself would not simply include <code>[\r\n]</code> in a solution without elaborating on its limitations.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73493</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73493</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Mon, 31 Jan 2022 03:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Sat, 29 Jan 2022 03:40:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73438">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">extremely exceptional behavior of [\R] and [^\R]</p>
</blockquote>
<p dir="auto">IMO there is no exceptional behavior here.<br />
Everything inside <code>[</code>…<code>]</code> is “one character”.</p>
<p dir="auto"><code>[\d]</code> is one digit character<br />
etc.</p>
<p dir="auto">Because <code>\R</code> is variable and can be one or two characters, its use inside <code>[</code>…<code>]</code> is not considered.</p>
<p dir="auto">Thus <code>[\R]</code> will match <code>R</code> (or <code>r</code> if not case sensitive specified).</p>
<p dir="auto">Easy enough to do <code>[\r\n]</code> anyway, right?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73441</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73441</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 29 Jan 2022 03:40:27 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Sat, 29 Jan 2022 02:42:29 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/73280">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">… the parts [^\R] just match any character … But … R … [and r if case sensitivity]</p>
</blockquote>
<p dir="auto">Yes, confirmed.</p>
<p dir="auto">Interestingly, however, I also confirmed that each of these sets:</p>
<pre><code class="language-txt">[\d]
[\w]
[\r]
[\n]
[\x31]
[^\d]
[^\w]
[^\r]
[^\n]
[^\x31]
</code></pre>
<p dir="auto"><strong>do</strong> match the specified character class or control character, or their complement, exactly “as advertised”.</p>
<p dir="auto">I couldn’t find any reference to the <em>extremely</em> <strong>exception</strong>al behavior of <code>[\R]</code> and <code>[^\R]</code> either in the npp docs or in the 1.7.8 Boost doc Peter linked to earlier.</p>
<p dir="auto">I can’t imagine I’m the first to notice this.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73438</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73438</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Sat, 29 Jan 2022 02:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Thu, 27 Jan 2022 18:48:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73359">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">dog|puppy</p>
</blockquote>
<p dir="auto">Also, since Boost::regex was derived as a PCRE, with roots in Perl, it still has the <a href="https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it" rel="nofollow ugc">TIMTOWTDI</a> philosophy:</p>
<ul>
<li><code>(?&lt;=dog|puppy)chow</code> can be represented as <code>((?&lt;=dog)|(?&lt;=puppy))chow</code><br />
<img src="/assets/uploads/files/1643228926299-b4c26801-84d9-4ccf-8b01-93d248c384a8-image.png" alt="b4c26801-84d9-4ccf-8b01-93d248c384a8-image.png" class=" img-fluid img-markdown" /></li>
<li><code>(?&lt;!dog|puppy)chow</code> can be represented as <code>((?&lt;!dog)(?&lt;!puppy))chow</code> <img src="/assets/uploads/files/1643229024308-f45582e2-354c-461c-b085-596ba7b700a2-image.png" alt="f45582e2-354c-461c-b085-596ba7b700a2-image.png" class=" img-fluid img-markdown" />
<ul>
<li>note that because of <a href="https://en.wikipedia.org/wiki/De_Morgan%27s_laws" rel="nofollow ugc">De Morgan’s Laws</a>, <code>NOT(A OR B)</code> becomes NOT(A) AND NOT(B)`</li>
</ul>
</li>
</ul>
<p dir="auto"><code>\d{1,500}</code> is admittedly harder to come up with an equivalent lookbehind that will work.  And by harder, I mean, I couldn’t in the last 5 minutes. (Specifically, we obviously don’t want to construct 500 alternatives manually, or fill up that space in the regex.  That would have been the “easy” alternative, but not practical.)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73363</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73363</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 27 Jan 2022 18:48:04 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 20:19:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73359">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">would be “easy-peasy”</p>
</blockquote>
<p dir="auto">I am sure if you can get that PR written and submitted to Boost::regex, they would be quite happy for your implementation. ;-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73361</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73361</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 26 Jan 2022 20:19:54 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 20:16:53 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> <a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">Open ended variable length negative look-behinds using subexpressions like <code>hello.*</code> would have huge performance implications.</p>
<p dir="auto">Upper-bounded variable length expressions like <code>dog|puppy</code> or <code>\d{1,500}</code> would be “easy-peasy” (ie, computers doing exactly what computer are good at doing), and extremely useful.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73359</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73359</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Wed, 26 Jan 2022 20:16:53 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 16:05:01 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/73342">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">there’s probably a good technical reason that it’s too hard to implement, and it’s not likely to change anytime soon.</p>
</blockquote>
<p dir="auto">I think the limitation probably is rooted in runtime complexity for the engine that would provide a poor user experience (way too long for it to examine every possible match, potential for engine catastrophic overflow, etc.).  Just my hunch.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73343</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73343</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 26 Jan 2022 16:05:01 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 16:00:06 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> said in <a href="/post/73341">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> said in <a href="/post/73339">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">It would be nice if this issue could be fixed sometime.</p>
</blockquote>
<p dir="auto">Because there is no equivalent for a negative lookbehind, doesn’t mean there’s an issue that could be “fixed”.</p>
</blockquote>
<p dir="auto">The lookbehind fixed-length restriction is caused by the Boost::regex library, not by anything Notepad++ does.  So the issue would have to be fixed there.</p>
<p dir="auto">To find more of the history of Boost::regex, and how long they’ve known about that restriction, I went to <a href="https://www.boost.org/doc/libs/" rel="nofollow ugc">https://www.boost.org/doc/libs/</a> (I kept cutting stuff out of the <a href="https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#lookahead" rel="nofollow ugc">1.78 URL</a> until I found a page that listed what other versions were available), and looked at old versions until I found the earliest Boost::regex that I noticed lookbehind syntax documented: <a href="https://www.boost.org/doc/libs/1_33_1/libs/regex/doc/syntax_perl.html" rel="nofollow ugc">v1.33.1</a> from 2004 – where they already note that restriction. If they’ve known about that limitation since 2004 and never gotten rid of that restriction, there’s probably a good technical reason that it’s too hard to implement, and it’s not likely to change anytime soon.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73342</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73342</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 26 Jan 2022 16:00:06 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 15:48:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> said in <a href="/post/73339">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">It would be nice if this issue could be fixed sometime.</p>
</blockquote>
<p dir="auto">It’s just a coincidence that <code>\K</code> can be used as a variable length positive lookbehind.<br />
Because there is no equivalent for a negative lookbehind, doesn’t mean there’s an issue that could be “fixed”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73341</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73341</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 26 Jan 2022 15:48:38 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 15:15:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73303">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">Both positive and negative look-behinds have this limitation (perhaps what you meant to say).</p>
</blockquote>
<p dir="auto">Yes, that’s what I meant. My apologies for the possible misunderstanding.</p>
<p dir="auto">Anyway, although both lookbehinds share such limitation, they differ because in the case of the positive lookbehind we have at our disposal the alternative of the operator \K, but no operator for the negative one.</p>
<p dir="auto">It would be nice if this issue could be fixed sometime.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73339</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73339</guid><dc:creator><![CDATA[astrosofista]]></dc:creator><pubDate>Wed, 26 Jan 2022 15:15:37 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 02:19:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73311">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a>’s \v trick does work with conventional UTF-8 \r\n line endings; it’s a more tolerant way of simply specifying \n, and would also handle other non-standard line ending formats.</p>
</blockquote>
<p dir="auto">I don’t think it has value.  If you need to match \r\n then \v\v will match it, but it will also match other things (that maybe aren’t wanted), so…no real point in it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73316</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73316</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 26 Jan 2022 02:19:46 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Wed, 26 Jan 2022 01:18:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> ,</p>
<p dir="auto">Sorry, I misread.  Time to stop trying to think for the evening, apparently</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73313</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73313</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 26 Jan 2022 01:18:04 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 23:11:28 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> said in <a href="/post/73310">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">A \v is always only one character, when it matches.</p>
</blockquote>
<p dir="auto">Good point. But <a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a>’s trick does work with conventional UTF-8 \r\n line endings; it’s a more tolerant way of simply specifying \n, and would also handle other non-standard line ending formats.</p>
<p dir="auto">Your comment reminds me that it’s risky to get too used to throwing \v around: if used in a matched text expression which will be replaced, it’s easy to inadvertently destroy a pristine file’s uniform line endings.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73311</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73311</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Tue, 25 Jan 2022 23:11:28 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 22:54:03 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">replace \R by a \v</p>
</blockquote>
<p dir="auto">This doesn’t make sense in the desired usage above.<br />
A <code>\R</code> can be one or two characters, thus not fixed length.<br />
A <code>\v</code> is always only one character, when it matches.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73310</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 25 Jan 2022 22:54:03 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 22:49:30 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> My comment pertains to the two kinds of look-behind, positive <code>(?&lt;=</code> and negative <code>(?&lt;!</code> (and I’ve tested both), and makes no mention of the two kinds of look-aheads.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73308</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73308</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Tue, 25 Jan 2022 22:49:30 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 22:31:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73303">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">Both positive and negative look-behinds have this limitation (perhaps what you meant to say).</p>
</blockquote>
<p dir="auto">Nope.</p>
<p dir="auto"><a href="https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.lookahead" rel="nofollow ugc">https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.lookahead</a></p>
<p dir="auto">vs</p>
<p dir="auto"><a href="https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.lookbehind" rel="nofollow ugc">https://www.boost.org/doc/libs/1_78_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.lookbehind</a></p>
<p dir="auto">Notice that only the lookbehind has the <code>pattern must be of fixed length</code> caveat; the lookahead can be variable width.</p>
<p dir="auto">And it’s very easy to test:<br />
<strong>lookbehind</strong><br />
<img src="/assets/uploads/files/1643149854376-c87c5b67-366e-4658-b3f6-cb93886d04c5-image.png" alt="c87c5b67-366e-4658-b3f6-cb93886d04c5-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><strong>lookahead</strong><br />
<img src="/assets/uploads/files/1643149816681-701eabc7-af01-412e-a0ca-23a0afa9b10b-image.png" alt="701eabc7-af01-412e-a0ca-23a0afa9b10b-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/73305</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73305</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 25 Jan 2022 22:31:02 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 22:08:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> said:</p>
<blockquote>
<p dir="auto">replace \R by a \v</p>
</blockquote>
<p dir="auto">Confirmed, and good to know, thanks. It’s strange that both constructs encode the 1 or 2 byte newline sequences, but only \v is valid.</p>
<blockquote>
<p dir="auto">a <strong>negative</strong> look-behind must be fixed width</p>
</blockquote>
<p dir="auto">Both positive and negative look-behinds have this limitation (perhaps what you meant to say).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73303</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73303</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Tue, 25 Jan 2022 22:08:43 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 16:22:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73277">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">(?&lt;!\R)\R(?!\R)<br />
(?&lt;[^\R])\R(?=[^\R])<br />
My best explanation is that \R can be either 1 or 2 bytes, but a look-behind must be fixed width. Any comment?</p>
</blockquote>
<p dir="auto">Since a negative look-behind must be fixed width, the way I use to get a valid expression is to replace <code>\R</code> by a <code>\v</code> or vertical tab, as follows:</p>
<p dir="auto"><code>(?&lt;!\v)\R(?!\R)</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/73289</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73289</guid><dc:creator><![CDATA[astrosofista]]></dc:creator><pubDate>Tue, 25 Jan 2022 16:22:52 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 14:11:16 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> Thanks, Guy.</p>
<p dir="auto">I’m noticing now why the 2nd regex I presented as invalid, <code>(?&lt;[^\R])\R(?=[^\R])</code>, is invalid: bad syntax due to missing = after &lt;.</p>
<p dir="auto">After that fix, it’s merely wrong (since the fancy \R construct is not decoded when appearing inside <code>[]</code> as you pointed out).</p>
<p dir="auto">Best,<br />
Neil</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73286</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73286</guid><dc:creator><![CDATA[Neil Schipper]]></dc:creator><pubDate>Tue, 25 Jan 2022 14:11:16 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 13:16:19 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Oh…, I didn’t see that you <strong>already</strong> gave the <strong>right</strong> solution to the OP :</p>
<p dir="auto"><strong><code>(?&lt;=[^\r\n])\R(?=[^\r\n])</code></strong></p>
<p dir="auto">Which is <strong>equivalent</strong> to my solution :</p>
<p dir="auto"><strong><code>(?&lt;!\n|\r)\R(?!\R)</code></strong></p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73281</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73281</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 25 Jan 2022 13:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 13:06:04 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alexander-hel" aria-label="Profile: alexander-hel">@<bdi>alexander-hel</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a>, and <strong>All</strong>,</p>
<p dir="auto">Yes, <strong>Neil</strong>, you’re right : just because of needed <strong>fixed</strong> length in <strong>look-behinds</strong>, the form <strong><code>(?&lt;!\R)\R(?!\R)</code></strong> is <strong>invalid</strong> as <strong><code>\R</code></strong> may match <strong>one</strong> or <strong>two consecutive</strong> chars</p>
<p dir="auto">As for your <strong>second</strong> attempt, the parts <strong><code>[^\R]</code></strong> just match <strong>any</strong> character</p>
<ul>
<li>
<p dir="auto">But the <strong>uppercase</strong> <strong><code>R</code></strong> if the <strong><code>Match case</code></strong> option is set</p>
</li>
<li>
<p dir="auto">But the letters <strong><code>R</code></strong> and <strong><code>r</code></strong> if the <strong><code>Match case</code></strong> option is <strong>not</strong> set</p>
</li>
</ul>
<hr />
<p dir="auto">Now a solution is to use a <strong>fixed</strong> length in the <strong>look-behind</strong> part :</p>
<p dir="auto">SEARCH <strong><code>(?&lt;!\n|\r)\R(?!\R)</code></strong></p>
<p dir="auto">Note that, if the <strong>last</strong> line ends with a <strong>line-break</strong>, it’s also <strong>matched</strong>. Indeed, the part <strong><code>(?!\R)</code></strong> is followed with <strong>nothing</strong> which is <strong>obviously</strong> different from <strong><code>\R</code></strong> )</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73280</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73280</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 25 Jan 2022 13:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to Remove unwanted Carriage Return on Tue, 25 Jan 2022 11:54:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/neil-schipper" aria-label="Profile: neil-schipper">@<bdi>neil-schipper</bdi></a> said in <a href="/post/73277">Remove unwanted Carriage Return</a>:</p>
<blockquote>
<p dir="auto">A perhaps more elegant find expression is <code>(?&lt;=[^\r\n])\R(?=[^\r\n])</code> in which case replacement text is nothing or a single space.</p>
<p dir="auto"><strong>To the regular crowd of regex experts:</strong> I was thrown by the fact that these are <strong>invalid</strong> expressions:</p>
<p dir="auto"><code>(?&lt;!\R)\R(?!\R)</code><br />
<code>(?&lt;[^\R])\R(?=[^\R])</code></p>
<p dir="auto">My best explanation is that <code>\R</code> can be either 1 or 2 bytes, but a look-behind must be fixed width. Any comment?</p>
</blockquote>
<p dir="auto">Hi, thank you for your reply, I tried this expression <code>(?&lt;=[^\r\n])\R(?=[^\r\n])</code> and it worked flawlessly.</p>
<p dir="auto">Thank you so much</p>
]]></description><link>https://community.notepad-plus-plus.org/post/73278</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/73278</guid><dc:creator><![CDATA[Alexander Hel]]></dc:creator><pubDate>Tue, 25 Jan 2022 11:54:19 GMT</pubDate></item></channel></rss>