<?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[Is there a possible way to REGEX &quot;Trim Leading Space&quot;?]]></title><description><![CDATA[<p dir="auto">Question. Frequently, after doing several sets of FIND/REPLACES (typically on 7-12 open files at once), I’ll end up with these random leading spaces left throughout the files. For these particular type of text files (.srt subtitle files), there can be NO leading spaces. Everything has to be aligned to the left. Most of the time, they’ll be in the form of leading spaces, but also could be leading ‘tabbed’ spaces.<br />
So, Notepad++ has the  “EDIT —&gt; BLANK OPERATIONS --&gt; TRIM LEADING SPACE” function, which takes care of all those pesky leading spaces &amp; tabbed spaces. But, even as a MACRO, I have to run that function one file at a time, and it’s slower than I’d like.<br />
I was hoping there might be a way to REGEX this, so I can use the FIND/REPLACE along with the “REPLACE ALL IN ALL OPENED DOCUMENTS”.<br />
If there is a way, maybe, to do this with REGEX?<br />
If yes, could you also show me what the TRIM TRAILING SPACE regex syntax would be?<br />
Thanks in advance! - Chris</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21696/is-there-a-possible-way-to-regex-trim-leading-space</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 04:48:45 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21696.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Aug 2021 21:10:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Fri, 20 Aug 2021 17:51:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/stefan-pendl" aria-label="Profile: Stefan-Pendl">@<bdi>Stefan-Pendl</bdi></a></p>
<p dir="auto">I guess you missed this from the OP’s first posting:</p>
<blockquote>
<p dir="auto">So, Notepad++ has the “EDIT —&gt; BLANK OPERATIONS --&gt; TRIM LEADING SPACE” function, which takes care of all those pesky leading spaces &amp; tabbed spaces. But, even as a MACRO, I have to run that function one file at a time, and it’s slower than I’d like.</p>
<p dir="auto">I was hoping there might be a way to REGEX this, so I can use the FIND/REPLACE along with the “REPLACE ALL IN ALL OPENED DOCUMENTS”.</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/69125</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69125</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 20 Aug 2021 17:51:28 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Fri, 20 Aug 2021 17:47:37 GMT]]></title><description><![CDATA[<p dir="auto">Try the menu entry “Edit =&gt; Line operations” this will allow trimming leading and trailing spaces as well as removing empty line.<br />
Everything is done by NPP and no regex is needed.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69124</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69124</guid><dc:creator><![CDATA[Stefan Pendl]]></dc:creator><pubDate>Fri, 20 Aug 2021 17:47:37 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Fri, 20 Aug 2021 15:23:42 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> Thank you for the hint. Been looking at the doc last night, and this morning. So, “CR LF” I think translates to \r \n<br />
So, maybe I’m finding [\r \n]+<br />
But not sure about the end of file. I see it’s \z, but why do I need to include that?<br />
Weird that when I turn on the SHOW ALL CHARACTERS, I don’t see any visible representation of end of file (like the CR LF’s).<br />
OK, yeah, I’m getting lost and overthinking it (or under thinking maybe).<br />
…<br />
assume the replace will be a single [\r \n]<br />
…<br />
I will do lots of trial and error this weekend! I’ll get there!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69116</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69116</guid><dc:creator><![CDATA[Chris Tanguay 0]]></dc:creator><pubDate>Fri, 20 Aug 2021 15:23:42 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Thu, 19 Aug 2021 21:46:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-tanguay-0" aria-label="Profile: Chris-Tanguay-0">@<bdi>Chris-Tanguay-0</bdi></a> said in <a href="/post/69100">Is there a possible way to REGEX "Trim Leading Space"?</a>:</p>
<blockquote>
<p dir="auto">DO NOT give me the answer</p>
</blockquote>
<p dir="auto">Okay, but I’ll give hints, since you seem to be getting lost in the docs.</p>
<blockquote>
<p dir="auto">So I need to come up with a regex, to run on multiple open text files, where each of the text files will have a random # of empty (no printable text) lines at the end (CR LF). Could be anywhere from 2 lines, up to 50.</p>
</blockquote>
<p dir="auto">So the things you need to figure out how to do are “match the CRLF end-of-line sequence” <a href="https://npp-user-manual.org/docs/searching/#control-characters" title="control characters" rel="nofollow ugc">🛈</a>, “match one or more of the previous token” <a href="https://npp-user-manual.org/docs/searching/#multiplying-operators" title="multiplying operator" rel="nofollow ugc">🛈</a>, and “match the end of the file” <a href="https://npp-user-manual.org/docs/searching/#anchors" title="anchors" rel="nofollow ugc">🛈</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/69101</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69101</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 19 Aug 2021 21:46:21 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Thu, 19 Aug 2021 21:40:25 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> First, thanks. And second, understood. Trust me, I’ve been at that document daily. But, it’s a bit of a challenge for me to find my way (and sync) with the syntax. I’ve figured out several things myself, but others… not so much.</p>
<hr />
<p dir="auto">Allow me to at least mention another example (and good gravy, DO NOT give me the answer - especially if it’s an easy REGEX, and I’m sure it is), but hear me out.<br />
So I need to come up with a regex, to run on multiple open text files, where each of the text files will have a random # of empty (no printable text) lines at the end (CR LF). Could be anywhere from 2 lines, up to 50.<br />
I need to remove all of those extra blank lines, EXCEPT for 1. After the last character of printable text, I need just 1 “CR LF” sequence and that’s it. See photos. Now, to me, that already sounds complicated.<br />
So, I will go to the document, and try to figure this out myself. I do wish it was a bit more interactive, so I could maybe pop in a search term to get myself closer to the good stuff. Anyway, heading there now. Of course, if this one is tricky, help a guy out!<br />
from this:<br />
<img src="/assets/uploads/files/1629409181979-01.jpg" alt="01.jpg" class=" img-fluid img-markdown" /><br />
to this:<br />
<img src="/assets/uploads/files/1629409207581-02.jpg" alt="02.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/69100</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69100</guid><dc:creator><![CDATA[Chris Tanguay 0]]></dc:creator><pubDate>Thu, 19 Aug 2021 21:40:25 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Thu, 19 Aug 2021 21:15:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-tanguay-0" aria-label="Profile: Chris-Tanguay-0">@<bdi>Chris-Tanguay-0</bdi></a> ,</p>
<p dir="auto">At this point, you’ve asked enough regex questions in the forum that really, you should be reading the official regular expression documentation in the online user manual at <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">https://npp-user-manual.org/docs/searching/#regular-expressions</a>, and trying to figure these out for yourself.  The trim-leading and trim-trailing are not overly complicated expressions, and the user manual covers the meaning of each individual piece.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69099</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69099</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 19 Aug 2021 21:15:29 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Thu, 19 Aug 2021 21:12:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-tanguay-0" aria-label="Profile: Chris-Tanguay-0">@<bdi>Chris-Tanguay-0</bdi></a> said in <a href="/post/69096">Is there a possible way to REGEX "Trim Leading Space"?</a>:</p>
<blockquote>
<p dir="auto">TRIM TRAILING SPACE regex syntax would be?</p>
</blockquote>
<p dir="auto">Sorry, didn’t see that.  FIND = <code>\h+$</code> (one or more spaces, followed by end of line)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69098</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69098</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 19 Aug 2021 21:12:54 GMT</pubDate></item><item><title><![CDATA[Reply to Is there a possible way to REGEX &quot;Trim Leading Space&quot;? on Thu, 19 Aug 2021 21:12:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-tanguay-0" aria-label="Profile: Chris-Tanguay-0">@<bdi>Chris-Tanguay-0</bdi></a> ,</p>
<p dir="auto">Regular expression mode, FIND <code>^\h+</code> (beginning of line, followed by 1 or more horizontal spaces (basically, spaces and tabs) and REPLACE with empty</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69097</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69097</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 19 Aug 2021 21:12:09 GMT</pubDate></item></channel></rss>