<?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[Delete number strings in the middle of lines of data]]></title><description><![CDATA[<p dir="auto">line of data:<br />
3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	3.2215E+02	1.00000E+00	5.55663E-01</p>
<p dir="auto">2000-1000 lines of data, I only need the first and last two numbers of each line, Notepad++v7.8.5; found a question &amp; response that seemed to fit for a smaller line of data:</p>
<p dir="auto">Find: ^(.{12}).{107}<br />
Replace: (\1)0000000000</p>
<p dir="auto">It seemed straightforward, but can’t seem to adapt it to mine. (BTW, I use a couple of regexp but with little understanding)</p>
<p dir="auto">thanks<br />
pmw7070</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/19219/delete-number-strings-in-the-middle-of-lines-of-data</link><generator>RSS for Node</generator><lastBuildDate>Fri, 08 May 2026 09:00:29 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19219.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Apr 2020 23:54:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Sat, 18 Apr 2020 09:54:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi, @craksoft, and <strong>All</strong>,</p>
<p dir="auto">You said :</p>
<blockquote>
<p dir="auto">So this long thing (?-s)(?&lt;=\d{4}-\d\d-\d\d)\h+.{8} is 6 number ?</p>
</blockquote>
<p dir="auto">I don’t know what you means, <strong>exactly</strong> !?</p>
<p dir="auto">The regex expression <strong><code>(?-s)(?&lt;=\d{4}-\d\d-\d\d)\h+.{8}</code></strong> deletes <strong>blanks</strong> characters and the <strong>next</strong> <strong><code>8</code></strong> characters, when preceded by a <strong>date</strong>, with the <strong><code>YYYY-MM-DD</code></strong> format. No more, no less :-)</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52778</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52778</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 18 Apr 2020 09:54:41 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 22:37:20 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/52765">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">(?-s)(?&lt;=\d{4}-\d\d-\d\d)\h+.{8}</p>
</blockquote>
<p dir="auto">So this long thing (?-s)(?&lt;=\d{4}-\d\d-\d\d)\h+.{8}  is 6 number ?<br />
Still thank it work you made my escape of selecting and deleting few hours of work ^^</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52769</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52769</guid><dc:creator><![CDATA[cracksoft]]></dc:creator><pubDate>Fri, 17 Apr 2020 22:37:20 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 22:24:29 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @craksoft, and <strong>All</strong>,</p>
<p dir="auto">If I <strong>fully</strong> understood your needs, you would like to <strong>delete</strong> the part after a <strong>date</strong>, which, I suppose, is the <strong>hour</strong> part ?</p>
<p dir="auto">If so :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?-s)(?&lt;=\d{4}-\d\d-\d\d)\h+.{8}</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search mode</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">For <strong>regex documentation</strong>, follow this link :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/52765</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52765</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 17 Apr 2020 22:24:29 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 22:16:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cracksoft" aria-label="Profile: cracksoft">@<bdi>cracksoft</bdi></a> **edit I may be on the right track I just found front the pdf you provide in this post space = \s if i’m not wrong?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52763</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52763</guid><dc:creator><![CDATA[cracksoft]]></dc:creator><pubDate>Fri, 17 Apr 2020 22:16:12 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 22:11:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cracksoft" aria-label="Profile: cracksoft">@<bdi>cracksoft</bdi></a> said in <a href="/post/52761">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> I was working on a *papier wen i notice i had to replace averything after a (space)<br />
exemple 2020-04-10 21,25,25</p>
<p dir="auto">I found the pdf pud i’m just Dum<br />
how to remove every regular expresion:  21,25,25<br />
so everything after the year-month-day?<br />
And sorry If I did broke few rules éditor Notepad++<br />
*edit</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/52762</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52762</guid><dc:creator><![CDATA[cracksoft]]></dc:creator><pubDate>Fri, 17 Apr 2020 22:11:33 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 22:02:25 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> I was working on a paper wen i notice i had to replace averything after a (space)<br />
exemple 2020-04-10 21,25,25</p>
<p dir="auto">I found the pdf pud i’m just Dum<br />
how to remove every regular expresion:  21,25,25<br />
so everything after the year-month-day?<br />
And sorry If I did broke few rules éditor Notepad++</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52761</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52761</guid><dc:creator><![CDATA[cracksoft]]></dc:creator><pubDate>Fri, 17 Apr 2020 22:02:25 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Mon, 06 Jul 2020 09:02:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>,</p>
<p dir="auto">Your replacement <strong>cannot</strong> work because, when the <strong>search</strong> regex matches the string <strong><code>XXX</code></strong>, due to the different <strong>alternatives</strong>, the <strong>group <code>2</code></strong> is the <strong>only</strong> group <strong>defined</strong>, anyway :-((</p>
<p dir="auto">In addition, seemingly, you’re <strong>not</strong> interested by the <strong>group <code>1</code></strong>, itself, but <strong>only</strong> with the <strong>replacement</strong> string of this group , so that you would like something like <strong><code>(?2\U</code>REPLACEMENT of (<code>\1</code>)<code>\E)</code></strong> !!</p>
<hr />
<p dir="auto">Let’s imagine the text <strong>sample</strong>, below, which is used in all <strong>subsequent</strong> tests :</p>
<pre><code class="language-diff">Xxx
XXX
XXX---Xxx
</code></pre>
<p dir="auto">Then with the regex S/R :</p>
<pre><code class="language-z">SEARCH    (?x-i)   ^(Xxx)$ | ^(XXX)$ | (\2---\1)
Groups :            1         2        3

REPLACE   \r\nGroup 1 &gt;\1&lt;\r\nGroup 2 &gt;\2&lt;\r\nGroup 3 &gt;\3&lt;\r\n
</code></pre>
<p dir="auto">We get :</p>
<pre><code class="language-z">Group 1 &gt;Xxx&lt;
Group 2 &gt;&lt;
Group 3 &gt;&lt;


Group 1 &gt;&lt;
Group 2 &gt;XXX&lt;
Group 3 &gt;&lt;

XXX---Xxx
</code></pre>
<p dir="auto">As explained above, the <strong>search</strong> regex does match the <strong><code>Xxx</code></strong> and <strong><code>XXX</code></strong> strings but <strong>fails</strong> to find the <strong><code>XXX---xxx</code></strong> because when trying the <strong><code>3rd</code></strong> alternative, the groups <strong><code>\1</code></strong> and <strong><code>\2</code></strong> are <strong>not</strong> defined</p>
<hr />
<p dir="auto">OK, let’s try <strong>another</strong> syntax, using <strong>sub-routine</strong> calls <strong><code>(?#)</code></strong> :</p>
<pre><code class="language-z">SEARCH    (?x-i)   ^(Xxx)$ | ^(XXX)$ | ((?2)---(?1))
Groups :            1         2        3

REPLACE   \r\nGroup 1 &gt;\1&lt;\r\nGroup 2 &gt;\2&lt;\r\nGroup 3 &gt;\3&lt;\r\n
</code></pre>
<p dir="auto">Text turns into :</p>
<pre><code class="language-z">Group 1 &gt;Xxx&lt;
Group 2 &gt;&lt;
Group 3 &gt;&lt;


Group 1 &gt;&lt;
Group 2 &gt;XXX&lt;
Group 3 &gt;&lt;


Group 1 &gt;&lt;
Group 2 &gt;&lt;
Group 3 &gt;XXX---Xxx&lt;
</code></pre>
<p dir="auto">This time, the result is <strong>better</strong> as, when matching the string <strong><code>XXX---xxx</code></strong>, with the <strong>alternative</strong> <strong><code>((?2)---(?1))</code></strong>, it makes <strong>reference</strong> to groups <strong><code>1</code></strong> and <strong><code>2</code></strong>, <strong>outside</strong> the alternative matched, due to the <strong><code>(DEFINE)</code></strong> syntax !</p>
<p dir="auto">However, we don’t get the groups <strong><code>1</code></strong> and <strong><code>2</code></strong>, <strong>individually</strong></p>
<hr />
<p dir="auto">Let’s use, again, an <strong>other</strong> syntax, where any <strong>sub-routine</strong> call <strong><code>(?#)</code></strong> is <strong>embedded</strong> in parentheses, <strong>itself</strong>, so <strong><code>((?#))</code></strong></p>
<pre><code class="language-z">SEARCH    (?x-i)   ^(Xxx)$ | ^(XXX)$ | ((?2))---((?1))
Groups :            1         2        3        4 

REPLACE   \r\nGroup 1 &gt;\1&lt;\r\nGroup 2 &gt;\2&lt;\r\nGroup 3 &gt;\3&lt;\r\nGroup 4 &gt;\4&lt;\r\n
</code></pre>
<p dir="auto">Just note that the <strong><code>3rd</code></strong> alternative is <strong>not</strong> embedded, itself, between <strong>parentheses</strong>. After execution, we’re left with :</p>
<pre><code class="language-z">Group 1 &gt;Xxx&lt;
Group 2 &gt;&lt;
Group 3 &gt;&lt;
Group 4 &gt;&lt;


Group 1 &gt;&lt;
Group 2 &gt;XXX&lt;
Group 3 &gt;&lt;
Group 4 &gt;&lt;


Group 1 &gt;&lt;
Group 2 &gt;&lt;
Group 3 &gt;XXX&lt;
Group 4 &gt;Xxx&lt;
</code></pre>
<p dir="auto">Ah!.. ,now, when the regex engine tries the <strong><code>3rd</code></strong> <strong>alternative</strong>, it does match the string <strong><code>XXX-Xxx</code></strong> and, in <strong>replacement</strong>, we note that groups <strong><code>3</code></strong> and <strong><code>4</code></strong> ( which are <strong>identical</strong> to groups <strong><code>2</code></strong> and <strong><code>1</code></strong>, <strong>respectively</strong>, <strong>not</strong> part of the <strong>present</strong> match ), are both <strong>defined</strong> :-))</p>
<p dir="auto">So, using a more <strong>natural</strong> example, below :</p>
<pre><code class="language-z">SEARCH    (?x-i)   ^(Xxx)$ | ^(XXX)$ | ((?2))---((?1))
Groups :            1         2        3        4 

REPLACE   (?1ABC)(?2DEF)(?3Group 1 = \4 and Group 2 = \3)
</code></pre>
<p dir="auto">The <strong>sample</strong> text :</p>
<pre><code class="language-diff">Xxx
XXX
XXX---Xxx
</code></pre>
<p dir="auto">is changed into :</p>
<pre><code class="language-diff">ABC
DEF
Group 1 = Xxx and Group 2 = XXX
</code></pre>
<hr />
<p dir="auto">However, there’s still a <strong>problem</strong>, as, in your example, you would like to refer to the <strong>replacement</strong> part of a group, which does <strong>not</strong> participate to the <strong>overall</strong> match, anyway ! More <strong>complicated</strong>…</p>
<p dir="auto">We must find a way :</p>
<ul>
<li>
<p dir="auto">To <strong>match</strong> and <strong>capture</strong> the string <strong><code>XXX</code></strong></p>
</li>
<li>
<p dir="auto">To <strong>capture</strong> the string <strong><code>ZZZ</code></strong>, in the <strong>same</strong> alternative, although the string <strong><code>ZZZ</code></strong> would <strong>not</strong> be part of the <strong>overall</strong> match</p>
</li>
</ul>
<p dir="auto">Still <strong>searching</strong> !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52759</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52759</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 06 Jul 2020 09:02:12 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Fri, 17 Apr 2020 12:34:59 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></p>
<p dir="auto">Maybe getting really off-topic now, but with the “DEFINE” stuff it got me thinking about a similar “problem” I have.  I say “problem” because it is nothing I can’t workaround, but I’m wondering if there is a better solution.</p>
<p dir="auto">Consider:</p>
<p dir="auto">search: <code>(?-i)(Xxx)|(XXX)|(Yyy)</code><br />
replace: <code>(?1Zzz)(?2ZZZ)(?3Www)</code></p>
<p dir="auto">This would convert this text: <code>The quick Xxx Yyy jumped over the lazy XXX</code> into <code>The quick Zzz Www jumped over the lazy ZZZ</code></p>
<p dir="auto">So please don’t consider the <em>wrong</em> problem. What I have is a simplified example of something more complicated, and the above is just for illustration.</p>
<p dir="auto">What I’d like to do is to NOT have to specify the capitalized version of <code>ZZZ</code> in the replace, but rather use the <code>Zzz</code> text without respecifying it (important!) in combination with a <code>\U</code> option.</p>
<p dir="auto">So in pseudo-regex, because I know this won’t work, without even trying it:</p>
<p dir="auto">replace: <code>(?1Zzz)(?2\U${1}\E)(?3Www)</code></p>
<p dir="auto">So I was just wondering if you had any thoughts on this.  TIA.  :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52742</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52742</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 17 Apr 2020 12:34:59 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Sun, 17 Jul 2022 12:00:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Yes, <strong>Alan</strong>, I’m agree with you that <strong>named</strong> groups should <strong>not</strong> be numbered by the regex <strong>engine</strong> and, thus, the user should only use them, as <strong>backreferences</strong>, with their <strong>names</strong>, in search and/or replacement !</p>
<p dir="auto">However, the <strong><code>.NET</code></strong> regex engine, has an <strong>intelligent</strong> way to have the <strong>best</strong> of both worlds ! Indeed, the <strong><code>.NET</code></strong> regex engine scans all <strong>unnamed</strong> groups, <strong>first</strong>, numbering them from value <strong><code>1</code></strong>, then <strong>re</strong>-scans the regex, <strong>continuing</strong> to number all the <strong>named</strong> groups, from after the <strong>greatest</strong> number used in <strong>unnamed</strong> groups ;-))</p>
<p dir="auto">In the <strong>old</strong> version, below, of the <strong><code>Regular-Expressions</code></strong> manual, of <strong><code>Jan Goyvaerts</code></strong> ( <strong>creator</strong> of the <strong><code>Regular-expressions.info</code></strong> site ),</p>
<p dir="auto"><a href="https://www.princeton.edu/~mlovett/reference/Regular-Expressions.pdf" rel="nofollow ugc">https://www.princeton.edu/~mlovett/reference/Regular-Expressions.pdf</a></p>
<p dir="auto">it is said, pages <strong><code>36-37</code></strong></p>
<blockquote>
<p dir="auto">Names and Numbers for Capturing Groups :</p>
</blockquote>
<blockquote>
<p dir="auto">Here is where things get a bit ugly. Python and PCRE treat named capturing groups just like unnamed capturing groups, and number both kinds from left to right, starting with one. The regex <strong><code>(a)(?P&lt;x&gt;b)(c)(?P&lt;y&gt;d)</code></strong> matches <strong>abcd</strong> as expected. If you do a search-and-replace with this regex and the replacement <strong><code>\1\2\3\4</code></strong>, you will get <strong>abcd</strong>. All four groups were numbered from left to right, from one till four. Easy and logical.</p>
</blockquote>
<blockquote>
<p dir="auto">Things are quite a bit more complicated with the .NET framework. The regex <strong><code>(a)(?&lt;x&gt;b)(c)(?&lt;y&gt;d)</code></strong> again matches <strong>abcd</strong>. However, if you do a search-and-replace with <strong><code>$1$2$3$4</code></strong> as the replacement, you will get <strong>acbd</strong>. Probably not what you expected.</p>
</blockquote>
<blockquote>
<p dir="auto">The .NET framework does number named capturing groups from left to right, but numbers them after all the unnamed groups have been numbered. So the unnamed groups (a) and (c) get numbered first, from left to right, starting at one. Then the named groups <strong><code>(?&lt;x&gt;b)</code></strong> and <strong><code>(?&lt;y&gt;d)</code></strong> get their numbers, continuing from the unnamed groups, in this case: three.</p>
</blockquote>
<blockquote>
<p dir="auto">To make things simple, when using .NET’s regex support, just assume that named groups do not get numbered at all, and reference them by name exclusively.</p>
</blockquote>
<p dir="auto">But, with the <strong><code>Boost</code></strong> regex engine of <strong>Notepad++</strong>, we have to make do with the <strong>usual</strong> numbering of the groups, which just does <strong>one</strong> regex scan and <strong>numbers</strong> any group, <strong>named</strong> or <strong>not</strong>, one after the other !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52715</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52715</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 17 Jul 2022 12:00:48 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Wed, 15 Apr 2020 17:48:37 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/52608">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">(?(DEFINE)…)</p>
</blockquote>
<p dir="auto">It’s a nice construct.  It is documented here for those that don’t know:</p>
<p dir="auto"><a href="https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html" rel="nofollow ugc">https://www.boost.org/doc/libs/1_70_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html</a></p>
<p dir="auto">as</p>
<pre><code class="language-z">(?(DEFINE)never-exectuted-pattern) Defines a block of code that is never executed and matches no characters: this is usually used to define one or more named sub-expressions which are referred to from elsewhere in the pattern.
</code></pre>
<p dir="auto">I don’t think it has a mention in the official Notepad++ docs, though.</p>
<p dir="auto">It doesn’t mean a lot if you simply read it, but a lot of value is added with a concrete example such as that provided by <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">One thing that I don’t like about it is that it consumes a capture group number.  Wouldn’t it be better to work with named and not numbered groups?  Indeed the docs say “…define one or more <em>named</em> sub-expressions…” so this would be equivalent for “my” regex (regex A) above:</p>
<pre><code class="language-z">(?x-si)    (    ?(DEFINE)    (?&lt;ALAN&gt;    (?&lt;![.\w+-]) [+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)? (?![.\w])    )    )        (^(?P&gt;ALAN)\h|(?P&gt;ALAN)$)
</code></pre>
<p dir="auto">But alas, even though I’ve used a group named <code>ALAN</code> above, it is equivalent to group #1, thus a possible equivalency use case could look like this:</p>
<pre><code class="language-z">(?x-si)    (    ?(DEFINE)    (?&lt;ALAN&gt;    (?&lt;![.\w+-]) [+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)? (?![.\w])    )    )        (^(?1)\h|(?1)$)
</code></pre>
<p dir="auto">Note that the difference is, even though I’ve named the group <code>ALAN</code> at “define” time, I refer to it as <code>1</code> when actually used.</p>
<p dir="auto">So why is this a downside?  Well, because it couples the left side (definition) with the right side (use).  Maybe I have a library of definitions, that I want to largely ignore (except their names), and I’m wanting to write a regex I’m going to use to match some data–maybe in the regex I want to backrefer to my <em>own</em> capture group #1.  Well, because of the coupling, group #1 would already be in use.</p>
<p dir="auto">Ok, so maybe it is a slight downside that wouldn’t come up often, but, I just happened to encounter that scenario recently…  :-)</p>
<p dir="auto">Did this turn into a Boost regex forum accidentally, or what?!?  So sorry…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52644</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52644</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 15 Apr 2020 17:48:37 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Thu, 16 Apr 2020 18:19:31 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: paul-whaley">@<bdi>paul-whaley</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/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Truly original, these  <strong><code>3</code></strong> possible <strong>interpretations</strong> ;-)) Hence the necessity for <strong>OPs</strong> to always <strong>describe</strong> their needs, in a <strong>rigorous</strong> way !</p>
<hr />
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, I think that your regex, to catch a <strong>number</strong>, could even be <strong>improved</strong> !</p>
<p dir="auto">First, I added the possibility to match a possible <strong>sign</strong>, in <strong>front</strong> of the number ( obvious )</p>
<p dir="auto">Secondly, if we test your regex <strong><code>\b\d+\.?\d*(?:E[+-]?\d+)?\b</code></strong>, against the <strong>malformed</strong> numbers, below, it <strong>wrongly</strong> matches something ! For instance, when it matches <strong>03</strong>, in the third line the <strong>\b</strong> assertion which is a location between a <strong>non</strong>-word char and a <strong>word</strong> char suppose it’s OK as, the minus sign, before <strong>03</strong> is, indeed, a <strong>non</strong> word char !</p>
<pre><code class="language-z">.5          Wrongly matches the string 5

.5E+02      Wrongly matches the string 5E+02

.E-03       Wrongly matches the string 03

.E+07       Wrongly matches the string 07

23.         Wrongly matches the string 23
</code></pre>
<p dir="auto">So, here is my solution, which do <strong>not</strong> use at all the <strong><code>\b</code></strong> <strong>assertion</strong> :</p>
<p dir="auto"><strong><code>(?&lt;![.\w+-])[+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)?(?![.\w])</code></strong>, meaning that any <strong>number</strong> :</p>
<ul>
<li>
<p dir="auto"><strong>Cannot</strong> be preceded by, either, a <strong>word</strong> character, the <strong>decimal</strong> dot <strong><code>.</code></strong>, the <strong><code>+</code></strong> sign or the <strong><code>-</code></strong> sign</p>
</li>
<li>
<p dir="auto"><strong>Cannot</strong> be followed by, either, a <strong>word</strong> character or the <strong>decimal</strong> dot <strong><code>.</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">Now, I’m going to tell you about a <strong>little-known</strong> structure : a <strong>conditional</strong> regex syntax, <strong><code>(?(Condition)........)</code></strong>, where the condition is the <strong>reserved</strong> word <strong><code>DEFINE</code></strong>, in <strong>upper</strong> case. The condition <strong>DEFINE</strong> is <strong>always</strong> <strong><code>FALSE</code></strong> so the contents of this <strong>conditional</strong> structure will <strong>never</strong> be part of the regex.</p>
<p dir="auto">It seems <strong>pointless</strong> ! Make no mistake : it allows you to define a kind of <strong>library</strong> of regular expressions, which you can use, at your leisure, to build your <strong>effective</strong> regular expression ;-))</p>
<p dir="auto">For instance, let’s suppose we want to match a <strong><code>IPV4</code></strong> address : Each of the <strong><code>4</code></strong> parts are a <strong>byte</strong>, with value from <strong>0</strong> to <strong>255</strong>. To get this <strong>integer</strong>, we must build the regex <strong><code>25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d</code></strong></p>
<p dir="auto">Now, the general form of a <strong><code>IPV4</code></strong> address is <strong>\bByte(.Byte){3}\b</strong>. Thus, in order to match an <strong><code>IPV4</code></strong> address, we may use the <strong>conditional</strong> <strong><code>DEFINE</code></strong> syntax, below :</p>
<p dir="auto"><strong><code>(?(DEFINE)(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))\b(?1)(\.(?1)){3}\b</code></strong></p>
<hr />
<p dir="auto">You could say: why don’t you prefer the <strong>simple</strong> regex, below ?</p>
<p dir="auto"><strong><code>\b(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(?1)){3}\b</code></strong></p>
<p dir="auto">Well, let’s suppose that there are <strong><code>3</code></strong> <strong>different</strong> ways to match an  <strong><code>IPV4</code></strong> address :</p>
<p dir="auto">Then, your <strong>regex</strong> would have been changed into :</p>
<p dir="auto"><strong><code>\b((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(?1)){3}|...2nd alternative...|...3rd alternative...)\b</code></strong></p>
<p dir="auto">But, when the <strong><code>2nd</code></strong> or <strong><code>3rd</code></strong> alternative matches, the <strong>group<code>1</code></strong> is <strong>not</strong> defined any more and you <strong>cannot</strong> use it in the <strong>other</strong> alternatives ! With the <strong>conditional</strong> <strong><code>DEFINE</code></strong> syntax, there is <strong>still</strong> possible :</p>
<p dir="auto"><strong><code>(?(DEFINE)(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))\b((?1)(\.(?1)){3}|...2nd alternative...|...3rd alternative)\b</code></strong></p>
<hr />
<p dir="auto">BTW, even using the simple syntax, it’s important to see the <strong>difference</strong> between these <strong>two</strong> regexes :</p>
<ul>
<li>
<p dir="auto"><strong><code>\b(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.\1){3}\b</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\b(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(?1)){3}\b</code></strong></p>
</li>
</ul>
<p dir="auto">Well :</p>
<ul>
<li>
<p dir="auto">The <strong>former</strong> regex would <strong>only</strong> match <strong><code>IPV4</code></strong> addresses like <em>45.45.45.45</em>, <em>0.0.0.0</em>, <em>127.127.127.127</em>, as the <strong>back-reference</strong> <strong><code>\1</code></strong> refers to the <strong>value</strong> of <strong>group <code>1</code></strong></p>
</li>
<li>
<p dir="auto">Whereas the <strong>later</strong> would find any <strong>valid</strong> <strong><code>IPV4</code></strong> address, because the <strong><code>(?1)</code></strong> syntax are similar to a <strong>subroutine</strong>, in a programming language, and refers to regex <strong>itself</strong> <strong><code>25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">Let’s go back to the <strong><code>DEFINE</code></strong> condition. The <strong>nice</strong> thing is that it allows you to define <strong>more than one</strong> regex/group :</p>
<p dir="auto">For instance, let’s imagine that you analyze a <strong>DNA</strong> genetic sequence and that you want to <strong>highlight</strong> certain <strong>combinations</strong> of the <strong><code>3</code></strong> <strong>elementary</strong> parts, below :</p>
<ul>
<li>
<p dir="auto"><strong><code>ATT.{12,}?ATT</code></strong> ( Zone <strong><code>A</code></strong> )</p>
</li>
<li>
<p dir="auto"><strong><code>TAG.{9}TAG</code></strong> ( Zone <strong><code>B</code></strong> )</p>
</li>
<li>
<p dir="auto"><strong><code>CCC.*?CCC</code></strong> ( Zone <strong><code>C</code></strong> )</p>
</li>
</ul>
<p dir="auto">Now, from these <strong>elementary</strong> parts, let’s assume that the <strong>combinations</strong> we’re looking for, in this <strong>DNA</strong> sequence, are <strong>three</strong> :</p>
<ul>
<li>
<p dir="auto"><code>A</code>CCCTTT<code>B</code></p>
</li>
<li>
<p dir="auto"><code>CAC</code></p>
</li>
<li>
<p dir="auto"><code>B</code>GAT<code>C</code>GAT<code>A</code></p>
</li>
</ul>
<p dir="auto">Then, you could build the regex :</p>
<p dir="auto"><strong><code>(?(DEFINE)(ATT.{12,}?ATT)(TAG.{9}TAG)(CCC.*?CCC))(?1)CCCTTT(?2)|(?3)(?1)(?3)|(?2)GAT(?3)GAT(?1)</code></strong></p>
<p dir="auto">or, with the <strong>Free-spacing</strong> mode :</p>
<p dir="auto"><strong><code>(?x) (?(DEFINE)   (ATT.{12,}?ATT)   (TAG.{9}TAG)   (CCC.*?CCC))   (?1)CCCTTT(?2)   |   (?3)(?1)(?3)   |   (?2)GAT(?3)GAT(?1)</code></strong></p>
<p dir="auto"><strong>Any</strong> alternative, in the <strong>right</strong> part of the regex, is <strong>functional</strong>, because the <strong>elementary</strong> parts <strong><code>A</code></strong>, <strong><code>B</code></strong>  and <strong><code>C</code></strong> are defined, <strong>once and for all</strong>, due to the <strong>conditional</strong> <strong><code>DEFINE</code></strong> structure in the <strong>left</strong> part of the regex</p>
<p dir="auto">Test these <strong>two</strong> regex syntaxes against the <strong>DNA</strong> sequence, below :</p>
<pre><code class="language-diff">GCTAATTCGGCTGATATCGATTCCCTTTTAGGGACTTACGTAGCCATGGATCCCATGCATGCCCATTCGGCTGATATCGATTCCCTGCCCGGATTTCTAGGGACTTACGTAGGATCCCATGCATGCCCGATATTCGGCTGATATCGATTTAAGGGCTA
</code></pre>
<hr />
<p dir="auto">To end, let’s apply all these notions to the <strong>OP</strong>’s problem :</p>
<p dir="auto">Let’s assume this <strong>single</strong> line of numbers :</p>
<pre><code class="language-ruby">+1.1111E-01 -2.2222E+02 +3.3333E-03 -4.4444E+04 5.5555E-05 +6.6666E+06 -7.7777E-07 8.8888E+08 -9.9999E-09
</code></pre>
<p dir="auto">If we use the <strong>conditional</strong> <strong><code>DEFINE</code></strong> structure and the <strong>free-spacing</strong> mode <strong><code>(?x)</code></strong>, you can write, these <strong><code>3</code></strong> following regexes :</p>
<pre><code class="language-z">SEARCH :

Regex A  :  (?x-si) (?(DEFINE) ( (?&lt;![.\w+-]) [+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)? (?![.\w]) ) ) .*? ( ^ (?1)\h       | (?1)       $ )  #  @Alan         flavor
Regex B  :  (?x-si) (?(DEFINE) ( (?&lt;![.\w+-]) [+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)? (?![.\w]) ) ) .*? ( ^ (?1)\h       | (?1)\h(?1) $ )  #  @Astrosofista flavor
Regex C  :  (?x-si) (?(DEFINE) ( (?&lt;![.\w+-]) [+-]?\d+(?:\.\d+)?(?:E[+-]?\d+)? (?![.\w]) ) ) .*? ( ^ (?1)\h(?1)\h | (?1)\h(?1) $ )  #  @PeterJones   flavor

REPLACE  :  \2
</code></pre>
<p dir="auto">And we get the <strong><code>3</code></strong> results below :</p>
<pre><code class="language-z">+1.1111E-01 -9.9999E-09                            @Alan         flavor , with Regex A
+1.1111E-01 8.8888E+08 -9.9999E-09                 @Astrosofista flavor , with Regex B
+1.1111E-01 -2.2222E+02 8.8888E+08 -9.9999E-09     @PeterJones   flavor , with Regex C
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52608</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52608</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 16 Apr 2020 18:19:31 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 19:51:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> said in <a href="/post/52598">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">which I see you thought I meant wasn’t “up to grade”</p>
</blockquote>
<p dir="auto">Not at all !</p>
<p dir="auto">And the “cautionary” stuff is well-noted as well.  We’re all in charge of our own data.<br />
And I think the OP was truly okay anyway <em>unless</em> he was going to do a backupless <em>Replace in Files</em> … there is always UNDO!</p>
<p dir="auto">And BTW, <code>\S</code> --that’s capital S-- <em>is</em> getting more workout in my own regex solutions these days!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52599</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52599</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 14 Apr 2020 19:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 19:16:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: Paul-Whaley">@<bdi>Paul-Whaley</bdi></a> said in <a href="/post/52552">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">I only need the first and last two numbers of each line,</p>
</blockquote>
<p dir="auto">Oh what a tangled web we weave. So 4 people got 3 different answers. Now I’m confused, all 3 have a glimmer of truth from the statement the OP made. I guess we need the OP to provide more info and especially the before/after “shot” of the data.</p>
<p dir="auto">Sorry <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> I awkwardly referred to your solution, which I see you thought I meant wasn’t “up to grade”. Actually I was trying to applaud it as great use of the “negative” class of "whitespace. My beef was with the OP providing a regex from some unknown location and stating they had little knowledge of how to “edit” it to suit. I was providing a cautionary tale to them.</p>
<p dir="auto">The 1 example line, whilst seemingly regimented data was actually not “in my mind”.  Most fields were 10 characters long, the last 2 were 11 characters long. Use of the provided regex (albeit edited) would have been an issue as possibly any of the fields may have changed between the 10 and 11 characters making the use of a regex without ability to detect these changes “very dangerous”.</p>
<p dir="auto">I understand where <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> comes from with a more defined regex, however I think the one thing we CAN see in the example is the data ONLY contains scientific numbers in a “clearly” defined format. I was happy with <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> use of the (negative) whitespace class to define the boundaries.</p>
<p dir="auto">Cheers<br />
my 2c worth<br />
Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52598</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52598</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 14 Apr 2020 19:16:33 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 14:02:33 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/52572">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">[0-9.E±]+ The problem with this subexpression is that it would match EEEEEEEEEEEEEEEEEEEEE or E+E-E+E-</p>
</blockquote>
<p dir="auto">Sure, but there are limits as to how far I’m willing to go, especially when it isn’t demonstrated (with good data sample by the OP) that it is needed.  :-)</p>
<p dir="auto">My goal was just to give the nod to <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> when he said <code>regex is very dangerous (on the wrong data) as it provides no exceptions or “quality” control.</code></p>
<blockquote>
<p dir="auto">I guess it is a language issue. I’m English-speaking all the way, but not for 100% of my life, maybe 85%?<br />
Hmm… I wouldn’t have guessed that.</p>
</blockquote>
<p dir="auto">I did a better calculation, it’s actually 93% of my life.<br />
I double-checked with my mother, who at the moment is living with me.  Sometimes this fact is :-) and sometimes it is :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52574</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52574</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 14 Apr 2020 14:02:33 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 13:18:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: Paul-Whaley">@<bdi>Paul-Whaley</bdi></a> said first,</p>
<blockquote>
<p dir="auto">I only need the first and last two numbers of each line</p>
</blockquote>
<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,</p>
<blockquote>
<p dir="auto">I took this to mean “first and last…two numbers on each line”</p>
</blockquote>
<p dir="auto">So, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> interpreted it as “first and last, for a total of two”; <a class="plugin-mentions-user plugin-mentions-a" href="/user/astrosofista" aria-label="Profile: astrosofista">@<bdi>astrosofista</bdi></a> interpreted it as “first (one) and last two, for a total of three”; I interpreted it as “first (two) and last two, for a total of four”.</p>
<p dir="auto">This is why giving <em>before</em> <strong>and</strong> <em>after</em> data is so critical when requesting help with <em>any</em> search-and-replace question, no matter how clear your statement is in your own head.</p>
<blockquote>
<p dir="auto">I guess it is a language issue.  I’m English-speaking all the way, but not for 100% of my life, maybe 85%?</p>
</blockquote>
<p dir="auto">Hmm… I wouldn’t have guessed that.</p>
<blockquote>
<p dir="auto">I saw this technique mentioned recently in the Notepad++ documentation issues list on github, but I can’t recall just where, to cite it now. :-(</p>
</blockquote>
<p dir="auto">It’s because it was in comments on the <a href="https://github.com/notepad-plus-plus/npp-usermanual/pull/79" rel="nofollow ugc">PR#79</a>, not on an issue.</p>
<blockquote>
<p dir="auto"><code>[0-9.E+-]+</code></p>
</blockquote>
<p dir="auto">The problem with this subexpression is that it would match <code>EEEEEEEEEEEEEEEEEEEEE</code> or <code>E+E-E+E-</code></p>
<p dir="auto">Assuming that no number starts with just a decimal point (so 0.5 or 0.5E5 are okay, but .5 or .5E5 are not), then <code>\b([0-9]+\.?[0-9]*(?:E[+-]?\d+)?)\b</code> will work for each “number”, with the full expression of</p>
<ul>
<li>FIND = <code>^(\b\d+\.?\d*(?:E[+-]?\d+)?\b) ((?1)).*?((?1)) ((?1))$</code></li>
<li>REPLACE = <code>$1 $2 $3 $4</code></li>
<li>MODE = regular expression</li>
</ul>
<p dir="auto">will take the first two and last two from lines that have at least four valid numbers</p>
<pre><code class="language-txt">3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 3.2215E+02 1.00000E+00 5.55663E-01
# these next two lines won't match
.1 .2 .3 .4 .5 .6
.1E+15 .2E0 .3E-4 .4E-05 .5E5 .6E123
# beyond here should match again
0.1E+15 0.2E0 0.3E-4 0.4E-05 0.5E5 0.6E123
1E23 4E+56 7E-89 1E234 100.000
</code></pre>
<p dir="auto">to become</p>
<pre><code class="language-txt">
3.2215E+02 3.2215E+02 1.00000E+00 5.55663E-01
# these next two lines won't match
.1 .2 .3 .4 .5 .6
.1E+15 .2E0 .3E-4 .4E-05 .5E5 .6E123
# beyond here should match again
0.1E+15 0.2E0 0.5E5 0.6E123
1E23 4E+56 1E234 100.000
</code></pre>
<p dir="auto">Note that this example shows both things that <em>should</em> match and things that <em>shouldn’t</em> match.  This is again good practice when asking for search/replace help.</p>
<p dir="auto">-—</p>
<p dir="auto"><em>Do you want regex search/replace help?  Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you.  All example text should be marked as plain text using the <code>&lt;/&gt;</code> toolbar button or manual <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">Markdown syntax</a>; screenshots can be pasted from the clipbpard to your post using <code>Ctrl+V</code>. Show the data you have <strong>and</strong> the text you want to get from that data; include examples of things that <strong>should match</strong> and be transformed, <strong>and</strong> things that <strong>don’t match</strong> and should be left alone; show <strong>edge cases</strong> and make sure you examples are as <strong>varied</strong> as your real data.  Show the regex you already tried, <strong>and why</strong> you thought it should work; tell us what’s wrong with what you <strong>do</strong> get… Read the official <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">NPP Searching / Regex docs</a> and the forum’s <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Regular Expression FAQ</a>. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/52572</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52572</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 14 Apr 2020 13:18:13 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 12:24:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: Paul-Whaley">@<bdi>Paul-Whaley</bdi></a> said::</p>
<blockquote>
<p dir="auto">first and last two numbers of each line</p>
</blockquote>
<p dir="auto">I took this to mean “first and last…two numbers on each line”<br />
I guess it is a language issue.  I’m English-speaking all the way, but not for 100% of my life, maybe 85%?<br />
:-)</p>
<p dir="auto">The simplest change to what I provided earlier is:</p>
<p dir="auto"><em><strong>Find what</strong></em>: <code>(?-s)^(\S+).*?(\S+) (\S+)$</code><br />
<em><strong>Replace with</strong></em>: <code>\1 \2 \3</code></p>
<p dir="auto">But in a nod to <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: Terry-R">@<bdi>Terry-R</bdi></a> 's cautionary statements, perhaps this is better:</p>
<p dir="auto"><em><strong>Find what</strong></em>: <code>(?-s)^([0-9.E+-]+).*?([0-9.E+-]+) ([0-9.E+-]+)$</code><br />
<em><strong>Replace with</strong></em>: same</p>
<p dir="auto">This gives an opportunity to show a form that avoids duplication and the possibility of copy-and-paste errors.  This also works:</p>
<p dir="auto"><em><strong>Find what</strong></em>: <code>(?-s)^([0-9.E+-]+).*?((?1)) ((?1))$</code><br />
<em><strong>Replace with</strong></em>: same</p>
<p dir="auto">Note that instead of retyping <code>[0-9.E+-]+</code>, since that is the first capture group, I just referenced it as <code>(?1)</code> when I wanted to use it (two places) later in the expression.</p>
<p dir="auto">I saw this technique mentioned recently in the Notepad++ documentation issues list on github, but I can’t recall just where, to cite it now. :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52567</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52567</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 14 Apr 2020 12:24:17 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 03:32:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: Paul-Whaley">@<bdi>Paul-Whaley</bdi></a> said in <a href="/post/52552">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">Find: ^(.{12}).{107}<br />
Replace: (\1)0000000000<br />
It seemed straightforward, but can’t seem to adapt it to mine.</p>
</blockquote>
<p dir="auto">The regex you supplied does the following:<br />
<code>^</code> find the start of a line<br />
<code>(.{12})</code> capture 12 characters of any sort, <code>(</code> and <code>)</code> allows them to be returned, see <code>\1</code> in the replace field. The <code>.</code> generally means any character and can also include the end of line if the <code>. matches newline</code> box is ticked.<br />
<code>.{107}</code> means capture 107 characters, however without <code>(</code> and <code>)</code> around it you cannot return these in the replace field. It’s only possible use seems to be to set the pointer to another forward position, possibly the start of the next line so the regex can perform the same function again (using replace all button).<br />
The replace field returns capture group 1 within brackets followed by 10 zeros.</p>
<p dir="auto">This regex will require a regimented set of data, that is, the data must be of same length in each line as it will not cater for any differences. Rather it blindly captures the requisite number of characters.</p>
<p dir="auto">If your data is also regimented (fixed length) you can do similar, however I won’t supply such a regex. I would say that this type of regex is very dangerous (on the wrong data) as it provides no exceptions or “quality” control.</p>
<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>  regex provides such quality control. He did make a mistake, in not getting the last 2 fields, I’ll let him provide an updated answer. I was just replying to alert you to the danger of taking another regex (possibly out of context) and without the knowledge to interpret it and hope you can edit it to suit your needs.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52557</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52557</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 14 Apr 2020 03:32:05 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 01:20:53 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a></p>
<p dir="auto">I’m afraid your regex missed one number, as OP needs <strong>last two numbers</strong>.</p>
<p dir="auto">PS: At first sight, I misread it too.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52555</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52555</guid><dc:creator><![CDATA[astrosofista]]></dc:creator><pubDate>Tue, 14 Apr 2020 01:20:53 GMT</pubDate></item><item><title><![CDATA[Reply to Delete number strings in the middle of lines of data on Tue, 14 Apr 2020 00:54:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paul-whaley" aria-label="Profile: Paul-Whaley">@<bdi>Paul-Whaley</bdi></a> said in <a href="/post/52552">Delete number strings in the middle of lines of data</a>:</p>
<blockquote>
<p dir="auto">I only need the first and last two numbers of each line,</p>
</blockquote>
<p dir="auto">Try this:</p>
<p dir="auto">Open the <em><strong>Replace</strong></em> dialog by pressing <strong>Ctrl+h</strong> and then set up the following search parameters:</p>
<p dir="auto"><em><strong>Find what</strong></em> box: <code>(?-s)^(\S+).*?(\S+)$</code><br />
<em><strong>Replace with</strong></em> box: <code>\1 \2</code><br />
<em><strong>Search mode</strong></em> radiobutton: <em><strong>Regular expression</strong></em><br />
<em><strong>Wrap around</strong></em> checkbox: <strong>ticked</strong><br />
<em><strong>. matches newline</strong></em> checkbox: doesn’t matter (because the <code>(?-s)</code> leading off the <em>Find what</em> box contains an <code>s</code> variant)</p>
<p dir="auto">Then press the <em><strong>Replace All</strong></em> button.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/52554</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/52554</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 14 Apr 2020 00:54:38 GMT</pubDate></item></channel></rss>