<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: rex help?? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65406#M16242</link>
    <description>&lt;P&gt;@jpolvino, &lt;CODE&gt;default&lt;/CODE&gt; value of &lt;CODE&gt;max_match&lt;/CODE&gt; argument (if not specified) is &lt;CODE&gt;1&lt;/CODE&gt; (Refer to documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex&lt;/A&gt;). Which means even if there are multiple matches of regular expression in the same event, only the first match will be returned.&lt;/P&gt;

&lt;P&gt;This being an old post from 2012, I would expect that it is already resolved by now ;). If not sample of data would definitely help and Regular Expression behavior can be tested on sites like regex101.com.&lt;/P&gt;</description>
    <pubDate>Fri, 11 May 2018 17:09:56 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-05-11T17:09:56Z</dc:date>
    <item>
      <title>rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65398#M16234</link>
      <description>&lt;P&gt;hi..&lt;/P&gt;

&lt;P&gt;how can i tell splunk to pick the first occurence of regular expression from a single event.i have written a regular expression ,and in each single event i have two occurences of this rex expression..is it possbile to pick only the first occurence of rex expression??&lt;/P&gt;

&lt;P&gt;if so cab  you pls give me the syntax of the regular exp.&lt;/P&gt;

&lt;P&gt;thnx.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2012 15:26:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65398#M16234</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2012-12-16T15:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65399#M16235</link>
      <description>&lt;P&gt;Have the regex cover the whole event even after your match until the end. That way you will get the section you want to grab from your regex, then the rest is matched as well. Sometehing like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;yourfield&amp;gt;matchingexpression).+$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Dec 2012 16:00:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65399#M16235</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-12-16T16:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65400#M16236</link>
      <description>&lt;P&gt;You haven't thought about teaching this stuff have you Ayn?! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
Seriously. It seems we cannot live without regex or Rex, but I have yet to see a solid tutorial, or masterclass on the advanced stuff. Maybe I missed something, it happens. gskinner.com is very useful....but..&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2012 16:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65400#M16236</guid>
      <dc:creator>DaveSavage</dc:creator>
      <dc:date>2012-12-16T16:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65401#M16237</link>
      <description>&lt;P&gt;Can you me the extract query ??&lt;BR /&gt;
my sample event is some thing like this .&lt;/P&gt;

&lt;P&gt;&lt;SYSTEM&gt;&lt;BR /&gt;
&lt;LOGTIME&gt;12:10:12&lt;/LOGTIME&gt;&lt;BR /&gt;
......&lt;BR /&gt;
.&lt;BR /&gt;
.....&lt;BR /&gt;
.....&lt;/SYSTEM&gt;&lt;/P&gt;

&lt;P&gt;&lt;LOGTIME&gt;23:20:10&lt;/LOGTIME&gt;&lt;BR /&gt;
......&lt;BR /&gt;
......&lt;BR /&gt;
&lt;/P&gt;

&lt;P&gt;I have created field like this.&lt;/P&gt;

&lt;P&gt;sourcetype="sysdata" | rex field=_raw "logTime&amp;gt;(?&lt;LTIME&gt;[0-9:]*)&amp;lt;"  | top LTIME&lt;/LTIME&gt;&lt;/P&gt;

&lt;P&gt;this is not giving me proper results.&lt;/P&gt;

&lt;P&gt;In my sample event i want to extract the first occurence in my field LTIME .&lt;/P&gt;

&lt;P&gt;i.e 12:10:12 in this case ..how can i do it ?&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2012 19:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65401#M16237</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2012-12-16T19:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65402#M16238</link>
      <description>&lt;P&gt;I just told you that in my answer. What is it you don't understand in it?&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2012 20:54:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65402#M16238</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-12-16T20:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65403#M16239</link>
      <description>&lt;P&gt;This is unnecessary, and expensive in the case of a long event (though of course most events aren't). Any regex will normally stop after the first match unless you specifically ask for multiple matches. This is the default behavior of &lt;CODE&gt;rex&lt;/CODE&gt; as well as automatic extractions.&lt;/P&gt;

&lt;P&gt;Actually, rakesh's problem in particular is not a problem of multiple matches. Probably it's just a bad regex. e.g., case-sensitivity, quoting.&lt;/P&gt;

&lt;P&gt;I would also say there's probably a more fundamental solution where his events should probably be timestamped with the first logtime, and therefore he could probably use &lt;CODE&gt;_time&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2012 23:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65403#M16239</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-12-16T23:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65404#M16240</link>
      <description>&lt;P&gt;my events are not timestamped with the logtime gkanapathy..can you pls help me in picking up the first tag ..in my rex .&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2012 20:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65404#M16240</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2012-12-17T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65405#M16241</link>
      <description>&lt;P&gt;Have you used the max_match=1 option for rex?&lt;/P&gt;

&lt;P&gt;If the time you're trying to extract is always the first timestamp, then try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search | rex max_match=1 "(?&amp;lt;timestamp&amp;gt;^\d\d:\d\d:\d\d)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you can post a sanitized event, we can help more.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 15:24:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65405#M16241</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2018-05-11T15:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: rex help??</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65406#M16242</link>
      <description>&lt;P&gt;@jpolvino, &lt;CODE&gt;default&lt;/CODE&gt; value of &lt;CODE&gt;max_match&lt;/CODE&gt; argument (if not specified) is &lt;CODE&gt;1&lt;/CODE&gt; (Refer to documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex&lt;/A&gt;). Which means even if there are multiple matches of regular expression in the same event, only the first match will be returned.&lt;/P&gt;

&lt;P&gt;This being an old post from 2012, I would expect that it is already resolved by now ;). If not sample of data would definitely help and Regular Expression behavior can be tested on sites like regex101.com.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 17:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/65406#M16242</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-11T17:09:56Z</dc:date>
    </item>
  </channel>
</rss>

