<?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[replace first two spaces with - third space with tab]]></title><description><![CDATA[<p dir="auto">I’m new to notepad++ advanced search &amp; replace</p>
<p dir="auto">I am trying to edit a text file for importing into a database table, a sample line is like this:</p>
<p dir="auto">dd mon yyyy 1,234.56&lt;tab&gt;4,567.89&lt;tab&gt;…etc…  (&lt;tab&gt; denotes a tab between sets of numbers, dd-mon-yyyy are real dates)</p>
<p dir="auto">In order to properly bring dd mon yyyy in to a date field, I need it to look like dd-mon-yyyy</p>
<p dir="auto">If I put () \b in the search field it finds the spaces I need, but also finds the space after yyyy, which I want replaced by a tab, not a dash</p>
<p dir="auto">I need the end result to look like dd-mon-yyyy&lt;tab&gt;1,234.02 &amp; leave the rest of each line alone.</p>
<p dir="auto">I think this may be a 2 step process, first step to replace the first 2 spaces with dashes, second step to replace remaining spaces with tabs, but I’m stumped on how best to do it.</p>
<p dir="auto">Thanks in advance.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21901/replace-first-two-spaces-with-third-space-with-tab</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Nov 2026 09:00:50 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21901.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Sep 2021 21:23:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to replace first two spaces with - third space with tab on Wed, 29 Sep 2021 02:40:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/70124">replace first two spaces with - third space with tab</a>:</p>
<blockquote>
<p dir="auto">${1}-${2}-${3}\t</p>
</blockquote>
<p dir="auto">Thanks so much, exactly what I was looking for!</p>
<p dir="auto">Now that I have it done I’ll look closer at your solution &amp; figure out what it all means.</p>
<p dir="auto">It turns out the text file was a little wonky, all of the months but September were 3 letter, and the rest already had a tab like I wanted after the 4 digit year, but the September months had a space. So it was like <strong>31&lt;sp&gt;Aug&lt;sp&gt; 2021&lt;tab&gt;1234.56</strong> and <strong>01&lt;sp&gt;Sept&lt;sp&gt;2021&lt;sp&gt;6789.12</strong> - so it was just a matter of replacing all the Sept with Sep, then running your solution on them, then I ran the <code>() \b</code> in the search with <code>-</code> in the replace for the rest of them.</p>
<p dir="auto">In any case, I was able to generate an insert statement &amp; got all my rows into my database table, so thanks again!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70126</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70126</guid><dc:creator><![CDATA[Glen_Strom]]></dc:creator><pubDate>Wed, 29 Sep 2021 02:40:13 GMT</pubDate></item><item><title><![CDATA[Reply to replace first two spaces with - third space with tab on Tue, 28 Sep 2021 21:33:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/glen_strom" aria-label="Profile: Glen_Strom">@<bdi>Glen_Strom</bdi></a></p>
<blockquote>
<p dir="auto">I think this may be a 2 step process, first step to replace the first 2 spaces with dashes, second step to replace remaining spaces with tabs</p>
</blockquote>
<p dir="auto">Nope. A straightforward regex can handle it in one step.  my search thought would be “look for one or two <a href="https://npp-user-manual.org/docs/searching/#character-classes" rel="nofollow ugc">digits</a>, space, a 3-letter month, space, a four-digit year, space – capturing each of the tokens from the date into a separate <a href="https://npp-user-manual.org/docs/searching/#capture-groups-and-backreferences" rel="nofollow ugc">capture group</a>; replace with group1, hyphen, group2, hyphen, group3, tab”.  I would then translate that into regex-speak: FIND = <code>(\d{1,2}) (\w+) (\d{4})\x20</code> (I used <a href="https://npp-user-manual.org/docs/searching/#non-ascii-characters" rel="nofollow ugc"><code>\x20</code> for the final space</a> because it is easier to read/copy/paste in the forum; in your own regex, that could equally be a space character at the end of the FIND instead), REPLACE = <code>${1}-${2}-${3}\t</code>, SEARCH MODE = regular expression.</p>
<p dir="auto">That converts</p>
<pre><code>11 mon 2021 1,234.56&lt;tab&gt;4,567.89&lt;tab&gt;…etc
21 xxx 1999 1,234.56&lt;tab&gt;4,567.89&lt;tab&gt;…etc
</code></pre>
<p dir="auto">into</p>
<pre><code>11-mon-2021	1,234.56&lt;tab&gt;4,567.89&lt;tab&gt;…etc
21-xxx-1999	1,234.56&lt;tab&gt;4,567.89&lt;tab&gt;…etc
</code></pre>
<p dir="auto">which I think is what you want</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 literal 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>. To make <code>regex in red</code> (and so they keep their special characters like *), use backticks, like <code>`^.*?blah.*?\z`</code>. Screenshots can be pasted from the clipboard to your post using <code>Ctrl+V</code> to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. 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/70124</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70124</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 28 Sep 2021 21:33:48 GMT</pubDate></item></channel></rss>