<?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: Regex to capture values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243450#M72451</link>
    <description>&lt;P&gt;Basically i am looking for shippingResponse= or , as left boundaries and | as the right boundary. That would give me &lt;BR /&gt;
12R071,12R095,12R090,12R078&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2015 03:54:20 GMT</pubDate>
    <dc:creator>xvxt006</dc:creator>
    <dc:date>2015-09-28T03:54:20Z</dc:date>
    <item>
      <title>Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243445#M72446</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have events like below. I need to extract 4EU56, 4YB2. the number of lines between statictext and  Y-EER-RTY would vary. &lt;BR /&gt;
Sometimes I might not have anything, sometimes they could be 10, and sometimes they could be some other number. &lt;BR /&gt;
In the example below, I gave 2. So how can I get all of them between, and | for all of them till Y-EER-RTY?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;statictext
,4EU56|1|1|456|anotherstatictext
,4YB2|1|1|946|200930||||S_NW|anotherstatictext
 Y-EER-RTY
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Sep 2015 22:21:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243445#M72446</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-09-27T22:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243446#M72447</link>
      <description>&lt;P&gt;Hi xvxt006,&lt;/P&gt;

&lt;P&gt;based on the provided example you can use this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search here | rex max_match=0 "^,(?&amp;lt;myField&amp;gt;[^|]*)" | table myField
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will get everything between all &lt;CODE&gt;lines starting with , until the next |&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;based on the comments below, this is the correct answer&lt;/P&gt;

&lt;P&gt;Okay, try this regex it will use &lt;CODE&gt;shippingResponse=&lt;/CODE&gt; or &lt;CODE&gt;,&lt;/CODE&gt; which is not followed by a &lt;CODE&gt;]&lt;/CODE&gt; as left boundary and the next &lt;CODE&gt;|&lt;/CODE&gt; as right&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?:shippingResponse=|,)(?!\])(?&amp;lt;myField&amp;gt;[^\|]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Works on &lt;CODE&gt;regex101.com&lt;/CODE&gt; with your provided examples and returns the following matches:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; MATCH 1
 myField    [94-100]    `12R071`
 MATCH 2
 myField    [159-165]    `12R095`
 MATCH 3
 myField    [224-230]    `12R090`
 MATCH 4
 myField    [289-295]    `12R078`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Sun, 27 Sep 2015 22:32:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243446#M72447</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-27T22:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243447#M72448</link>
      <description>&lt;P&gt;Hi MuS, static test i mentioned has "," in it. So that won't work. &lt;/P&gt;

&lt;P&gt;Here is more realistic example of the event. I need 12R095,12R090,12R078&lt;/P&gt;

&lt;P&gt;|ItemBranch:|FulfillingBranch:|S|Line#:|GenMessage:Y|ShipMode:GR|ShipDate:,] shippingResponse=12R071|1|1|005|20150930||||S_NW|standard.ship.stocked.available&lt;BR /&gt;
,12R095|1|1|002|20150929||||S_NW|standard.ship.stocked.available&lt;BR /&gt;
,12R090|1|1|003|20151001||||S_NW|standard.ship.stocked.available&lt;BR /&gt;
,12R078|1|1|005|20150930||||S_NW|standard.ship.stocked.available&lt;BR /&gt;
Y-EER-RTY&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:23:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243447#M72448</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2020-09-29T07:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243448#M72449</link>
      <description>&lt;P&gt;Try this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search here | rex max_match=0 "(?!,\])[=,](?&amp;lt;myField&amp;gt;[^|]*)" | table myField
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2015 03:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243448#M72449</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-28T03:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243449#M72450</link>
      <description>&lt;P&gt;Hi Michael, &lt;/P&gt;

&lt;P&gt;this gives better results but still there is unwanted text. Just trying to understand what you wrote in that expression. &lt;BR /&gt;
Does this (?!,])[=,] mean that either either  "=" or ","   cannot not be preceeded by   ","  or "]" &lt;/P&gt;

&lt;P&gt;is there an email i can send you what i am seeing?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 03:29:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243449#M72450</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-09-28T03:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243450#M72451</link>
      <description>&lt;P&gt;Basically i am looking for shippingResponse= or , as left boundaries and | as the right boundary. That would give me &lt;BR /&gt;
12R071,12R095,12R090,12R078&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 03:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243450#M72451</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-09-28T03:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243451#M72452</link>
      <description>&lt;P&gt;Okay, try this regex it will use &lt;CODE&gt;shippingResponse=&lt;/CODE&gt; or &lt;CODE&gt;,&lt;/CODE&gt; which is not followed by a &lt;CODE&gt;]&lt;/CODE&gt; as left boundary and the next &lt;CODE&gt;|&lt;/CODE&gt; as right &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?:shippingResponse=|,)(?!\])(?&amp;lt;myField&amp;gt;[^\|]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Works on regex101.com with your provided examples and returns the following matches:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MATCH 1
myField [94-100]    `12R071`
MATCH 2
myField [159-165]   `12R095`
MATCH 3
myField [224-230]   `12R090`
MATCH 4
myField [289-295]   `12R078`
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2015 08:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243451#M72452</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-28T08:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243452#M72453</link>
      <description>&lt;P&gt;Thank you. This gives me an idea on how to tackle some other scenarios. Can you make this as Answer. don't have permissions to do that..&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 13:30:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243452#M72453</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2015-09-28T13:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to capture values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243453#M72454</link>
      <description>&lt;P&gt;update ping; modified the answer to be correct now&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2015 19:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-capture-values/m-p/243453#M72454</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-28T19:32:59Z</dc:date>
    </item>
  </channel>
</rss>

