<?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 - Extract till first set of numbers in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312574#M93581</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If I understand correctly, you just want to extract everything from start until the first set of numbers, but include that set of numbers in your token right?&lt;/P&gt;

&lt;P&gt;In that case, this is the regex I would use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;EXTRACTED_DATA&amp;gt;\D+\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval DATA = "ABCD_EFG_HIJ_9998_LNM_HASJ_kasldj_a781-4413-7708"
| rex field=DATA "^(?&amp;lt;EXTRACTED_DATA&amp;gt;\D+\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output (see picture below):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2508i7C311F143588A8AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2017 12:47:28 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2017-02-21T12:47:28Z</dc:date>
    <item>
      <title>Rex - Extract till first set of numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312572#M93579</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have following values in field - DATA for which I want to extract text from start till the first set of number.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ABCD_EFG_HIJ_9998_LNM_HASJ_kasldj_a781-4413-7708&lt;BR /&gt;
ABCD_EFG_4039_DATA_LOST_SAMPLE&lt;BR /&gt;
FG_GG_1386_NUM125679_HR_1111_GHH_KSN_JASKK&lt;BR /&gt;
ABCD_EFG_4039_DATA_7837_LOST_SAMPLE&lt;BR /&gt;
XYZ_1920_MM_KK_LL_DATAFORMAT_SAMPLE&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;What I want is to extract till first set of number, wherever it occurs, i.e.&lt;BR /&gt;
ABCD_EFG_HIJ_9998&lt;BR /&gt;
ABCD_EFG_4039&lt;BR /&gt;
FG_GG_1386&lt;BR /&gt;
ABCD_EFG_4039&lt;BR /&gt;
XYZ_1920&lt;/P&gt;

&lt;P&gt;Following rex I have tried :  &lt;CODE&gt;rex field=DATA "(?&amp;lt;EXTRACTED_DATA&amp;gt;.*\d{4})\_"&lt;/CODE&gt;  , also the Splunk provided field extraction but no luck.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312572#M93579</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2020-09-29T12:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rex - Extract till first set of numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312573#M93580</link>
      <description>&lt;P&gt;Hi harshal_chakranarayan,&lt;BR /&gt;
try this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "^(?&amp;lt;my_field&amp;gt;[^0-9]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can test it at &lt;A href="https://regex101.com/r/mkbCMt/1"&gt;https://regex101.com/r/mkbCMt/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312573#M93580</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-02-21T12:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rex - Extract till first set of numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312574#M93581</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If I understand correctly, you just want to extract everything from start until the first set of numbers, but include that set of numbers in your token right?&lt;/P&gt;

&lt;P&gt;In that case, this is the regex I would use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;EXTRACTED_DATA&amp;gt;\D+\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval DATA = "ABCD_EFG_HIJ_9998_LNM_HASJ_kasldj_a781-4413-7708"
| rex field=DATA "^(?&amp;lt;EXTRACTED_DATA&amp;gt;\D+\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output (see picture below):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2508i7C311F143588A8AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:47:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312574#M93581</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2017-02-21T12:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rex - Extract till first set of numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312575#M93582</link>
      <description>&lt;P&gt;Thanks for the answer, but I want the extraction including the first set of number&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312575#M93582</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2017-02-21T12:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Rex - Extract till first set of numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312576#M93583</link>
      <description>&lt;P&gt;Thanks, this work for me.&lt;BR /&gt;
Yes, I wanted the extraction to include first set of number.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 12:51:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Extract-till-first-set-of-numbers/m-p/312576#M93583</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2017-02-21T12:51:47Z</dc:date>
    </item>
  </channel>
</rss>

