<?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[[Regex] Remove all but last line]]></title><description><![CDATA[<p dir="auto">I often have to edit files that contain hundreds of lines (all urls begging with http or https)  When I do this i only need the last url.  It would speed my process if I could simply remove every line but the last one.  Would love if this is possible, I’m not great with regex but have tried many things and have been googling for months  with no luck.  Would appreciate any help.  Thank you</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/15091/regex-remove-all-but-last-line</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 23:17:08 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15091.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Jan 2018 03:51:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Regex] Remove all but last line on Sun, 14 Jan 2018 04:54:57 GMT]]></title><description><![CDATA[<p dir="auto">Thanks guy038 your second one worked perfectly for me.  Really appreciate it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/29465</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/29465</guid><dc:creator><![CDATA[Bobby Peters222]]></dc:creator><pubDate>Sun, 14 Jan 2018 04:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to [Regex] Remove all but last line on Sun, 14 Jan 2018 04:45:43 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @bobby-teters222, and <strong>All</strong>,</p>
<p dir="auto">It’ not clear, <strong>Bobby</strong>, if you’re speaking about :</p>
<ul>
<li>
<p dir="auto">The <strong>last non-empty</strong> line of your files</p>
</li>
<li>
<p dir="auto">The <strong>last</strong> line, beginning by the string <strong>http:</strong> or <strong>https:</strong></p>
</li>
</ul>
<p dir="auto">Anyway, here is the solutions for the <strong>both</strong> cases !</p>
<hr />
<ul>
<li>To <strong>delete</strong> all text till the <strong>last non-empty</strong> line, <strong>excluded</strong>, in  any scanned file, use the regex S/R :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?s).*\R(?=(?-s).+)</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">OPTIONS <strong><code>Wrap around</code></strong> and <strong><code>Regular expression</code></strong> ticked</p>
<p dir="auto">ACTION Click on the <strong><code>Replace All</code></strong></p>
<ul>
<li>To <strong>delete</strong> all text till the <strong>last</strong> line, beginning by <strong>http:</strong> or <strong>https:</strong>, <strong>excluded</strong>, in any scanned file, use the regex S/R :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?s).*\R(?=(?-s)https?:.+)</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">OPTIONS <strong><code>Wrap around</code></strong> and <strong><code>Regular expression</code></strong> ticked</p>
<p dir="auto">ACTION Click on the <strong><code>Replace All</code></strong></p>
<hr />
<p dir="auto">If you like that solution, I’ll give you, next time, some <strong>details</strong> on these <strong>regexes</strong> !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/29464</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/29464</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 14 Jan 2018 04:45:43 GMT</pubDate></item></channel></rss>