<?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 Help with regular expression extract and match in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496890#M138436</link>
    <description>&lt;P&gt;I have log file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:00 jon nginx: A[1234]B[56789] [0.1222]

11:00:00 dan service cloud: C[0078]D[12] F[2]

11:00:00 dan mongo_DB: D[0078]C[12]A[2]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1) Match nginx: and service cloud: but only extract “nginx” and “service cloud”, not “:”&lt;/P&gt;

&lt;P&gt;2) Regex match to whole part like this A[1234] but only want extract numbers between brackets like “1234”. (Between brackets have a different range of number N[234] or K[343443],..., And maybe have separator like [0.1222].)&lt;/P&gt;

&lt;P&gt;Any recommendation?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 16:36:01 GMT</pubDate>
    <dc:creator>indeed_2000</dc:creator>
    <dc:date>2019-12-04T16:36:01Z</dc:date>
    <item>
      <title>Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496890#M138436</link>
      <description>&lt;P&gt;I have log file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11:00:00 jon nginx: A[1234]B[56789] [0.1222]

11:00:00 dan service cloud: C[0078]D[12] F[2]

11:00:00 dan mongo_DB: D[0078]C[12]A[2]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1) Match nginx: and service cloud: but only extract “nginx” and “service cloud”, not “:”&lt;/P&gt;

&lt;P&gt;2) Regex match to whole part like this A[1234] but only want extract numbers between brackets like “1234”. (Between brackets have a different range of number N[234] or K[343443],..., And maybe have separator like [0.1222].)&lt;/P&gt;

&lt;P&gt;Any recommendation?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496890#M138436</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-04T16:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496891#M138437</link>
      <description>&lt;P&gt;Hi @ mehrdad_2000,&lt;BR /&gt;
if I correctly understand, you want to extract the numbers between brackets, is it correct?&lt;BR /&gt;
if this is your need, try this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+\w+\[(?&amp;lt;first_num&amp;gt;\d+)\]\w+\[(?&amp;lt;second_num&amp;gt;\d+)\][^\[]*\[(?&amp;lt;third_num&amp;gt;[^\]]*)\]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/vVIUkL/1"&gt;https://regex101.com/r/vVIUkL/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 16:56:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496891#M138437</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-04T16:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496892#M138438</link>
      <description>&lt;P&gt;Thank you for answer&lt;BR /&gt;
But I want to get all “A” an “B” ... grouped in related column. In each line location of A are different.&lt;BR /&gt;
This log is unstructured, and messy.&lt;BR /&gt;
I need to get them wherever there are in each line and group them.&lt;BR /&gt;
E.g. first_num all A&lt;BR /&gt;
Second_num all B ...&lt;/P&gt;

&lt;P&gt;Also some them separate by space others not. This is random&lt;BR /&gt;
E.g. A[324] B[5455]C[55] &lt;BR /&gt;
D[324] B[5455] A[55] &lt;/P&gt;

&lt;P&gt;First_num | second_num | &lt;BR /&gt;
324—————5455&lt;BR /&gt;
55————— 5455&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:11:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496892#M138438</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2020-09-30T03:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496893#M138439</link>
      <description>&lt;P&gt;Hi @mehrdad_2000,&lt;BR /&gt;
if you want to extract all the numbers after A and all the numbers after B without any order in your logs, you could use two different regexes, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| rex "A\[(?&amp;lt;A_field&amp;gt;\d+)"
| rex "B\[(?&amp;lt;B_field&amp;gt;\d+)"
| table A B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That you can test at &lt;A href="https://regex101.com/r/vVIUkL/2"&gt;https://regex101.com/r/vVIUkL/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 15:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496893#M138439</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-05T15:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496894#M138440</link>
      <description>&lt;P&gt;This is exactly what I want, thank you so much.&lt;BR /&gt;
In field extraction it work perfectly one by one, But when I write both of them like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;A\[(?\d+) | B\[(?\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;separate them with pipe it match all &lt;CODE&gt;A&lt;/CODE&gt; but some of &lt;CODE&gt;B&lt;/CODE&gt;!&lt;BR /&gt;&lt;BR /&gt;
Do have any idea about this?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 16:13:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496894#M138440</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-05T16:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496895#M138441</link>
      <description>&lt;P&gt;You cannot not do both at the same time, but you can do 1 with each like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "^\S+\s+\S+\s+(?&amp;lt;service&amp;gt;[^:]+)"
| rex max_match=0 "\[(?&amp;lt;numbers&amp;gt;\d+)\]"
| eval numbers=mvsort(numbers)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then, depending on what you mean, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| nomv numbers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval numbers_range = mvindex(numbers, 0) . " - " . mvindex(numbers, -1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2019 20:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496895#M138441</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-06T20:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496896#M138442</link>
      <description>&lt;P&gt;Hi @mehrdad_2000,&lt;BR /&gt;
Sorry but I cannot read you regex, please use the Code Sample button (1010101) otherwise I cannot help you.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 08:14:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496896#M138442</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-10T08:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496897#M138443</link>
      <description>&lt;P&gt;Of course it doesn't. They are TWO SEPARATE extractions.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 14:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496897#M138443</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-10T14:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496898#M138444</link>
      <description>&lt;P&gt;Exactly, I thought it can extract multiple fields with field extraction.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 15:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496898#M138444</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-10T15:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496899#M138445</link>
      <description>&lt;P&gt;As @woodcock told They are TWO SEPARATE extractions.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 15:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496899#M138445</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-10T15:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regular expression extract and match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496900#M138446</link>
      <description>&lt;P&gt;You need to structure the &lt;CODE&gt;|&lt;/CODE&gt; correctly.  See this example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="foo=bar, bat=baz"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| rex "(?:foo=(?&amp;lt;foo&amp;gt;\S+))|(?:bat=(?&amp;lt;bat&amp;gt;\S+))"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regular-expression-extract-and-match/m-p/496900#M138446</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-10T18:30:13Z</dc:date>
    </item>
  </channel>
</rss>

