<?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[Extract specific data from log files?]]></title><description><![CDATA[<p dir="auto">I have a log file that I need to extract specific data elements from.<br />
Example text:</p>
<pre><code>[22-12-20 21:16:04.521]   FROM LIVE   &lt;$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5411,34319,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:16:04.553]   auth accepted tag=9812120450668474 device=V2
[22-12-20 21:16:40.185]   FROM LIVE   &lt;02:PAYDONE=0000022851&gt;
[22-12-20 21:17:20.677]     TO LIVE   &lt;$011B4910:FleetCard_1:9812120450669349&gt;
[22-12-20 21:17:21.270]   FROM LIVE   &lt;$011B4910:FleetCard_10:1,49.48,1,1,200001,Fleet No,5237,34320,TARJETA,,49.48,,2,0,1&gt;
[22-12-20 21:17:21.333]   auth accepted tag=9812120450669349 device=V1
[22-12-20 21:18:44.345]   FROM LIVE   &lt;02:PAYDONE=0000022852&gt;
[22-12-20 21:19:16.399]   FROM LIVE   &lt;03:PAYDONE=0000022853&gt;
[22-12-20 21:20:18.292]     TO LIVE   &lt;$011B5150:FleetCard_1:9812120450669482&gt;
[22-12-20 21:20:19.073]   FROM LIVE   &lt;$011B5150:FleetCard_10:1,51.75,1,1,200001,Fleet No,2001,34321,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:20:19.167]   auth accepted tag=9812120450669482 device=V1
[22-12-20 21:21:53.536]     TO LIVE   &lt;$011B4B50:FleetCard_1:9812120450668854&gt;
[22-12-20 21:21:54.286]   FROM LIVE   &lt;$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:21:54.301]   auth accepted tag=9812120450668854 device=V2
[22-12-20 21:25:11.284]   FROM LIVE   &lt;02:PAYDONE=0000022854&gt;
[22-12-20 21:25:20.141]   FROM LIVE   &lt;04:PAYDONE=0000022855&gt;
</code></pre>
<p dir="auto">I want to extract like below</p>
<pre><code>Fleet No : 5411  tag :9812120450668474 
Fleet No:  5237  tag:9812120450669349
Fleet No : 2001  tag:9812120450669482
</code></pre>
<p dir="auto">This is my first question here and would like any support for above</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24007/extract-specific-data-from-log-files</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 02:54:31 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24007.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Jan 2023 17:21:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Extract specific data from log files? on Fri, 13 Jan 2023 14:15:47 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/zorba-greek" aria-label="Profile: zorba-greek">@<bdi>zorba-greek</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: michael-vincent">@<bdi>michael-vincent</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">A <strong>one way</strong> solution would be to use the following <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $ | ^ .+</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1Fleet No \: $1 tag \: $2:)</code></strong></p>
<p dir="auto">This regex :</p>
<ul>
<li>
<p dir="auto">Searches for <strong>two consecutive</strong> lines, <strong>without</strong> the <strong>ending</strong> line-break, containing the string <strong>Fleet No</strong>, with this <strong>exact</strong> case, in the <strong>first</strong> line and the string <strong>tag=</strong>, with this <strong>exact</strong> case, in the <strong>second</strong> one and replace these <strong>two</strong> lines with the string <strong>Fleet No : <code>$1</code> tag : <code>$2</code></strong>, where <strong><code>$1</code></strong> and <strong><code>$2</code></strong> are the numbers located after <strong>Fleet No</strong> and <strong>tag=</strong></p>
</li>
<li>
<p dir="auto">When <strong>no more</strong> line contains the string <strong>Fleet No</strong>, it graps <strong>all</strong> the remaining text till the <strong>very end</strong> of the file and <strong>deletes</strong> it</p>
</li>
</ul>
<hr />
<p dir="auto">So for instance, I will try to <strong>describe</strong> the process with this <strong>dummy</strong> example below :</p>
<pre><code class="language-diff">
FIRST alternative : (?xs-i) ^ .+? Fleet \x20 No , ( \d+ ) , .+? tag= ( \d+) .+? $


[22-12-20 21:18:44.345]   FROM LIVE   &lt;02:PAYDONE=0000022852&gt;CRLF
&lt;----------------------------------------------------------------
^                           .+?

[22-12-20 21:19:16.399]   FROM LIVE   &lt;03:PAYDONE=0000022853&gt;CRLF
-----------------------------------------------------------------
                            .+?

[22-12-20 21:21:54.286]   FROM LIVE   &lt;$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1&gt;CRLF
--------------------------------------------------------------------------------&gt;Fleet No,&lt;--&gt;&lt;--------------------------------
                            .+?                                                  Fleet No, \d+               .+?
                                                                                 Fleet No, $1
[22-12-20 21:21:54.301]   auth accepted tag=9812120450668854 device=V2CRLF
---------------------------------------&gt;tag=&lt;--------------&gt;&lt;--------&gt; ( line-break NOT included in the regex )
                .+?                     tag=   ( \d+ )          .+?   $
                                        tag=      $2


SECOND alternative : ^ .+


[22-12-20 21:25:11.284]   FROM LIVE   &lt;02:PAYDONE=0000022854&gt;CRLF
-----------------------------------------------------------------
^                               .+

[22-12-20 21:25:20.141]   FROM LIVE   &lt;04:PAYDONE=0000022855&gt;CRLF
----------------------------------------------------------------- ( End of file )
                                .+
</code></pre>
<hr />
<p dir="auto">Now, given the <strong>exact</strong> <em>INPUT</em> text, provided by <a class="plugin-mentions-user plugin-mentions-a" href="/user/zorba-greek" aria-label="Profile: zorba-greek">@<bdi>zorba-greek</bdi></a> :</p>
<pre><code class="language-diff">[22-12-20 21:16:04.521]   FROM LIVE   &lt;$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5411,34319,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:16:04.553]   auth accepted tag=9812120450668474 device=V2
[22-12-20 21:16:40.185]   FROM LIVE   &lt;02:PAYDONE=0000022851&gt;
[22-12-20 21:17:20.677]     TO LIVE   &lt;$011B4910:FleetCard_1:9812120450669349&gt;
[22-12-20 21:17:21.270]   FROM LIVE   &lt;$011B4910:FleetCard_10:1,49.48,1,1,200001,Fleet No,5237,34320,TARJETA,,49.48,,2,0,1&gt;
[22-12-20 21:17:21.333]   auth accepted tag=9812120450669349 device=V1
[22-12-20 21:18:44.345]   FROM LIVE   &lt;02:PAYDONE=0000022852&gt;
[22-12-20 21:19:16.399]   FROM LIVE   &lt;03:PAYDONE=0000022853&gt;
[22-12-20 21:20:18.292]     TO LIVE   &lt;$011B5150:FleetCard_1:9812120450669482&gt;
[22-12-20 21:20:19.073]   FROM LIVE   &lt;$011B5150:FleetCard_10:1,51.75,1,1,200001,Fleet No,2001,34321,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:20:19.167]   auth accepted tag=9812120450669482 device=V1
[22-12-20 21:21:53.536]     TO LIVE   &lt;$011B4B50:FleetCard_1:9812120450668854&gt;
[22-12-20 21:21:54.286]   FROM LIVE   &lt;$011B4B50:FleetCard_10:1,51.75,1,1,200001,Fleet No,5418,34322,TARJETA,,51.75,,3,0,1&gt;
[22-12-20 21:21:54.301]   auth accepted tag=9812120450668854 device=V2
[22-12-20 21:25:11.284]   FROM LIVE   &lt;02:PAYDONE=0000022854&gt;
[22-12-20 21:25:20.141]   FROM LIVE   &lt;04:PAYDONE=0000022855&gt;
</code></pre>
<p dir="auto">We get the <strong>expected</strong> <em>OUTPUT</em> text :</p>
<pre><code class="language-diff">Fleet No : 5411 tag : 9812120450668474
Fleet No : 5237 tag : 9812120450669349
Fleet No : 2001 tag : 9812120450669482
Fleet No : 5418 tag : 9812120450668854
</code></pre>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">In the <strong>search</strong> regex, I use the <strong>free-spacing</strong> mode, <strong><code>(?x)</code></strong>, for an <strong>easy</strong> reading of the <strong>different</strong> parts of this regex</p>
</li>
<li>
<p dir="auto">You probably noticed that <strong>all</strong> ranges of text, in my regex, need to be <strong>non-greedy</strong> ranges ( Syntax = <strong><code>.+?</code></strong> ), as <strong>each</strong> range must <strong>not</strong> contain, itself, the strings <strong>Fleet No</strong> and <strong>tag=</strong> nor the final <strong>line break</strong> !</p>
</li>
<li>
<p dir="auto">As this regex does <strong>not</strong> include the <strong>final</strong> line-break, it will keep them, as is, in the <em>OUTPUT</em> text</p>
</li>
<li>
<p dir="auto">The <strong>replacement</strong> regex <strong><code>(?1Fleet No \: $1 tag \: $2:)</code></strong> means :</p>
<ul>
<li>
<p dir="auto">IF a <strong>Fleet number</strong> is found ( <strong><code>(?1...</code></strong> ) it rewrites the string <strong>Fleet No :</strong>  followed with the <strong>Fleet</strong> number ( <strong><code>$1</code></strong> ), the string <strong>tag =</strong> and the <strong>tag</strong> number <strong><code>$2</code></strong>, all separated with <strong><code>space</code></strong> chars and <strong><code>colon</code></strong> chars when <strong>needed</strong></p>
</li>
<li>
<p dir="auto">ELSE it replaces with <strong>everything</strong> between the last <strong><code>:</code></strong> character, after <strong><code>$2</code></strong> and the <strong>end</strong> of the <strong>conditional</strong> replacement <strong><code>)</code></strong> i.e. <strong>nothing</strong> so it deletes <strong>all</strong> the <strong>remaining</strong> text till the <strong>very end</strong> of current file !</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Remark that the <strong>two first</strong> <strong><code>:</code></strong> chars, in replacement, are <strong>literal</strong> characters and must be <strong>escaped</strong>, in order to be <strong>rewritten</strong> as is when the <strong>group <code>1</code></strong> is <strong>present</strong></p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83275</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83275</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 13 Jan 2023 14:15:47 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Fri, 13 Jan 2023 03:50:14 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> ,</p>
<p dir="auto">I agree with your analysis. One can’t understand the more complex, nor how to come to figure it out, if they don’t do the baby steps.  I’m reminded myself, as I  take on doing another UDL for one of our older versions of dBASE for those still using it and wanting to use it in NPP, that I’ve started using Mark in NPP as a test bed of my fledgling regex instead of going straight to <a href="http://Regex101.com" rel="nofollow ugc">Regex101.com</a>, since it’s almost as interactive as their web page, but since they don’t have Boost as a test engine, it behooves me to do the work in NPP with the native regex, and I’ve found that Mark is a great way test my regex in stages.  Plus, sometimes, the problem has to be divided in two to accomplish it…like trimming the ellipsis and page numbers from a list of Commands from a doucment, to replacing the spaces with the hex equivalent to make it work in NPP, etc…</p>
<p dir="auto">Until I came to do this UDL for the language, I hadn’t even scratched the surface of NPP, and now that I have, I find myself in awe of the things it’s going to allow me to do…but only if I take it in baby steps.  :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83273</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83273</guid><dc:creator><![CDATA[Lycan Thrope]]></dc:creator><pubDate>Fri, 13 Jan 2023 03:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 19:39:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a>  , helpful …</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83258</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83258</guid><dc:creator><![CDATA[Zorba Greek]]></dc:creator><pubDate>Thu, 12 Jan 2023 19:39:10 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 18:38:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a> said in <a href="/post/83256">Extract specific data from log files?</a>:</p>
<blockquote>
<p dir="auto">An expert more versed than I may be able to help with a single stroke - for me, without a scripting solution, this is a multi-step process.</p>
</blockquote>
<p dir="auto">Don’t underestimate your abilities <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a>. Your answer is perfectly acceptable, and I would have also likely given the same. Often when providing solutions to those who are yet to understand the complexities of regex, doing it in several “easy” steps is easier to understand.</p>
<p dir="auto">The alternative would be to use alternation which is not so easy to understand for the uninitiated.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83257</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83257</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:38:15 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 18:27:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zorba-greek" aria-label="Profile: Zorba-Greek">@<bdi>Zorba-Greek</bdi></a> said in <a href="/post/83255">Extract specific data from log files?</a>:</p>
<blockquote>
<p dir="auto">i want to delete everything except the selected file</p>
</blockquote>
<p dir="auto">An expert more versed than I may be able to help with a single stroke - for me, without a scripting solution, this is a multi-step process.</p>
<p dir="auto">Now that you have the lines you want, use the Search =&gt; Mark menu item to bookmark the lines:</p>
<p dir="auto">Find what:</p>
<pre><code>Fleet No : \d{4} : \d{16}
</code></pre>
<p dir="auto">Check the “Bookmark line” checkbox:</p>
<p dir="auto"><img src="/assets/uploads/files/1673547990759-2eed987d-491e-4627-80f1-6b42ee57a2c2-image.png" alt="2eed987d-491e-4627-80f1-6b42ee57a2c2-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The right-click the bookmark margin and select “Copy Bookmarked Lines”, open a new tab and paste.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83256</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83256</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:27:17 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 18:05:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a> said in <a href="/post/83254">Extract specific data from log files?</a>:</p>
<blockquote>
<p dir="auto">\n\nFleet No : $1 tag : $2\n\n</p>
</blockquote>
<p dir="auto">just there,  i want to delete everything except the selected file</p>
<p dir="auto">![alt text](image url)<img src="/assets/uploads/files/1673546670269-captured.jpg" alt="Captured.JPG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/83255</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83255</guid><dc:creator><![CDATA[Zorba Greek]]></dc:creator><pubDate>Thu, 12 Jan 2023 18:05:14 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 17:48:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zorba-greek" aria-label="Profile: Zorba-Greek">@<bdi>Zorba-Greek</bdi></a></p>
<p dir="auto">Phew.</p>
<p dir="auto">The regex:</p>
<pre><code>Fleet No\,(\d{4})\,.*?auth accepted tag=(\d{16})
</code></pre>
<p dir="auto">with the “Regular expression” radio button and “. matches newline” checked will find your data.</p>
<p dir="auto">Using the replace dialogue on a copy of your file (this operation would be destructive), you could use:</p>
<pre><code>\n\nFleet No : $1 tag : $2\n\n
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1673545677710-558372d2-3628-41f7-abb5-2695c0ec67d9-image.png" alt="558372d2-3628-41f7-abb5-2695c0ec67d9-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83254</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83254</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:48:08 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 17:41:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-vincent" aria-label="Profile: Michael-Vincent">@<bdi>Michael-Vincent</bdi></a></p>
<p dir="auto">Its just an internal reference ,</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83253</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83253</guid><dc:creator><![CDATA[Zorba Greek]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:41:14 GMT</pubDate></item><item><title><![CDATA[Reply to Extract specific data from log files? on Thu, 12 Jan 2023 17:39:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zorba-greek" aria-label="Profile: Zorba-Greek">@<bdi>Zorba-Greek</bdi></a></p>
<p dir="auto">Please don’t let those 16-digit numbers above be bank card numbers … and if they are, please let them be obscured and you didn’t copy / paste real numbers, non-anonymized, into this public forum.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83252</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83252</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 12 Jan 2023 17:39:47 GMT</pubDate></item></channel></rss>