<?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 to build a regular expression that will capture multiple numbers in a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273629#M82507</link>
    <description>&lt;P&gt;If you are doing this at search time, then you would probably want the following in transforms.conf (you would reference the following transform in props.conf as well).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MVNumber]
REGEX  = (\d+-\d+):
FORMAT = Number::$1
MV_ADD = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And you would want to add the following to fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Number]
TOKENIZER = (\d+-\d+):
INDEXED = false
INDEXED_VALUE = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Dec 2016 18:20:44 GMT</pubDate>
    <dc:creator>rjthibod</dc:creator>
    <dc:date>2016-12-08T18:20:44Z</dc:date>
    <item>
      <title>How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273625#M82503</link>
      <description>&lt;P&gt;my log looks like below and i wanted to know if i could make a single regular expression to extract all xxx-xxx numbers &lt;/P&gt;

&lt;P&gt;The following messages were logged on 12/07/16 at 07:52:10.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0420-094: blah blah blah destination.
0423-245: blah blah blah  changed.
0420-098: blah blah blah  job.
0424-138: blah blah blah.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so if Regex is Number then i would like to see &lt;/P&gt;

&lt;P&gt;number &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0420-094
0423-245
0420-098
0424-138
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or to better understand if i do a stats count by number&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;number         |     Count
0420-094       |       1
0423-245       |       1
0420-098       |       1
0424-138       |       1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i know i can do multiple regex's for each one and then coalesce to merge them all, but if there's a better way then why not &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 15:42:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273625#M82503</guid>
      <dc:creator>shivarpith</dc:creator>
      <dc:date>2016-12-07T15:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273626#M82504</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search ... | rex "(?&amp;lt;number&amp;gt;[^:]*)" | stats count as Count by number 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 16:43:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273626#M82504</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-07T16:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273627#M82505</link>
      <description>&lt;P&gt;Thank you for the response but  the regex above will still pick the 1st number that came up in the log, i have a scenario where an event has 2-6 numbers like below but not limited to.&lt;BR /&gt;
0420-094&lt;BR /&gt;
0423-245&lt;BR /&gt;
0420-098&lt;BR /&gt;
0424-138&lt;/P&gt;

&lt;P&gt;i want regex to parse all the values that match the regex, i was looking at MV_ADD option but not sure if that would work.&lt;/P&gt;

&lt;P&gt;\n(?.*):&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 13:03:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273627#M82505</guid>
      <dc:creator>shivarpith</dc:creator>
      <dc:date>2016-12-08T13:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273628#M82506</link>
      <description>&lt;P&gt;Sorry, I interpreted your original post to be different log messages.  &lt;/P&gt;

&lt;P&gt;Is your sourcetype already correctly differentiating your multiline log events? If not, that needs be cleaned up first.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 18:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273628#M82506</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-08T18:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273629#M82507</link>
      <description>&lt;P&gt;If you are doing this at search time, then you would probably want the following in transforms.conf (you would reference the following transform in props.conf as well).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MVNumber]
REGEX  = (\d+-\d+):
FORMAT = Number::$1
MV_ADD = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And you would want to add the following to fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Number]
TOKENIZER = (\d+-\d+):
INDEXED = false
INDEXED_VALUE = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2016 18:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273629#M82507</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-08T18:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a regular expression that will capture multiple numbers in a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273630#M82508</link>
      <description>&lt;P&gt;thank you, i will try it out and post the update. thanks a lot&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 21:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-regular-expression-that-will-capture-multiple/m-p/273630#M82508</guid>
      <dc:creator>shivarpith</dc:creator>
      <dc:date>2016-12-08T21:35:24Z</dc:date>
    </item>
  </channel>
</rss>

