<?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: How can I build regex for specific field extraction? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374457#M110076</link>
    <description>&lt;P&gt;Try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval t="value02132018additionaltext"
|rex field=t "(?&amp;lt;a&amp;gt;[^\d]+)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 13 Feb 2018 15:11:11 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-02-13T15:11:11Z</dc:date>
    <item>
      <title>How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374454#M110073</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;

&lt;P&gt;I am sure this is a relatively easy regex to build but I was hoping for some assistance, my regex experience is still pretty rocky &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;One of my log values contains more information than I need, but the first "section" of the value is what I really want to pull out.  I can say that 100% of the time the value I want to extract is followed by today's date along with some more information.  For instance:&lt;/P&gt;

&lt;P&gt;Field=value02132018additionaltext&lt;/P&gt;

&lt;P&gt;In the above example, it would only be the "value" that I care about and want to strip everything after it.  Is this possible?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:55:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374454#M110073</guid>
      <dc:creator>bcarr12</dc:creator>
      <dc:date>2018-02-13T14:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374455#M110074</link>
      <description>&lt;P&gt;Hi bcarr12,&lt;BR /&gt;
if you're sure that in the value field there never are eight successive numbers, you can use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Field "(?&amp;lt;my_field&amp;gt;.*)\d{8}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;as you can test at &lt;A href="https://regex101.com/r/glpagP/1"&gt;https://regex101.com/r/glpagP/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:09:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374455#M110074</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-02-13T15:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374456#M110075</link>
      <description>&lt;P&gt;Hi @bcarr12,&lt;/P&gt;

&lt;P&gt;Can you please try regex with sed&lt;/P&gt;

&lt;P&gt;Run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval field1="value02132018additionaltext"
| rex field=field1 mode=sed "s/([a-z]*)\d+\w+/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So your query will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBasesearch&amp;gt; | rex field=&amp;lt;FIELDNAME&amp;gt; mode=sed "s/([a-z]*)\d+\w+/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:10:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374456#M110075</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-02-13T15:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374457#M110076</link>
      <description>&lt;P&gt;Try this run anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval t="value02132018additionaltext"
|rex field=t "(?&amp;lt;a&amp;gt;[^\d]+)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:11:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374457#M110076</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-13T15:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374458#M110077</link>
      <description>&lt;P&gt;Can you provide some more clarity on what kind of data is in the 'value' part? Otherwise it will be quite difficult to help you come up with a regex that is able to distinguish between the value part and the date and text.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374458#M110077</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-02-13T15:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374459#M110078</link>
      <description>&lt;P&gt;The regex provided a little further down in this question gets me very close:&lt;BR /&gt;
rex field=myfield mode=sed "s/([a-z]*)\d+\w+/\1/g"&lt;/P&gt;

&lt;P&gt;This command gets me the value I want 99% of the time and in a few cases a little bit more.  The data in the "value" is typically 6-8 characters long (not always 8 characters long but at most will not be more than 8 characters long), and alphanumeric.  It is then followed by today's date and some additional alphanumeric values after that.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:29:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374459#M110078</guid>
      <dc:creator>bcarr12</dc:creator>
      <dc:date>2018-02-13T15:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374460#M110079</link>
      <description>&lt;P&gt;Thank you!  This gets me very close to where I need to be.  I think if a condition is added to this to recognize that the value "ends" with a comma it will work properly.  Right now the extraction works correctly 99% of the time but in some cases also extracts some extra info at the end of the complete value.  So the field/value pair I am extracting is:&lt;/P&gt;

&lt;P&gt;field=valuemmddyyyyadditionaltext, nextfield=nextvalue&lt;/P&gt;

&lt;P&gt;It pulls the value out correctly almost every time, but is including some additional characters from the "additionaltext" part in a handful of cases.  So I think if the regex could basically be set to ignore everything in the value beginning with date code and ending with a comma, it will be exactly what I need (just the initial value and nothing else).&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374460#M110079</guid>
      <dc:creator>bcarr12</dc:creator>
      <dc:date>2018-02-13T15:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374461#M110080</link>
      <description>&lt;P&gt;Try this &lt;CODE&gt;&amp;lt;yourBasesearch&amp;gt;  | rex field=&amp;lt;FIELDNAME&amp;gt; mode=sed "s/([a-z]*)\d+\w+\,/\1/g"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 15:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374461#M110080</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2018-02-13T15:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374462#M110081</link>
      <description>&lt;P&gt;Hmm this causes the extraction to pull out more than is needed.  Thanks for your help, you've put me on the right path so I can work on this a bit more to fine tune.  Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 16:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374462#M110081</guid>
      <dc:creator>bcarr12</dc:creator>
      <dc:date>2018-02-13T16:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I build regex for specific field extraction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374463#M110082</link>
      <description>&lt;P&gt;Looks like this did the trick, updated w+ to S+&lt;/P&gt;

&lt;P&gt;rex field= mode=sed "s/([a-z]*)\d+\S+/\1/g"&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 16:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-build-regex-for-specific-field-extraction/m-p/374463#M110082</guid>
      <dc:creator>bcarr12</dc:creator>
      <dc:date>2018-02-13T16:11:16Z</dc:date>
    </item>
  </channel>
</rss>

