<?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 Will you help me create a regex to extract one or more lines with same heading in a single event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379256#M111129</link>
    <description>&lt;P&gt;Hello guys,&lt;/P&gt;

&lt;P&gt;I'm adding this to my search in order to extract fields :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 field=_raw "CC :' \d+' de DN : 'CN=(?&amp;lt;DNmanquante&amp;gt;[^,]+)[^']+'\n(- CODE \(serial : (?P&amp;lt;CRLmanquante&amp;gt;\d+)\) error.\n-+\n)+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Event example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CC :' 223' de DN : 'CN=XXX 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- CODE (serial : 1234) error.
---------------------------------------------------------
- CODE (serial : 5676) error.
---------------------------------------------------------
- CODE (serial : 5677) error.
---------------------------------------------------------
- CODE (serial : 5678) error.
---------------------------------------------------------
- CODE (serial : 5679) error.
---------------------------------------------------------
CC :' 224' de DN : 'CN=YYY 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get XXX 2025:1234,XXX 2025:5678...etc like a tree with 1 or more branches.&lt;/P&gt;

&lt;P&gt;The problem is it returns only last match : 5679&lt;/P&gt;

&lt;P&gt;Thanks a lot.&lt;/P&gt;

&lt;P&gt;Regex101 link : &lt;A href="https://regex101.com/r/M96VAN/2"&gt;https://regex101.com/r/M96VAN/2&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2018 15:04:40 GMT</pubDate>
    <dc:creator>splunkreal</dc:creator>
    <dc:date>2018-09-19T15:04:40Z</dc:date>
    <item>
      <title>Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379256#M111129</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;

&lt;P&gt;I'm adding this to my search in order to extract fields :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 field=_raw "CC :' \d+' de DN : 'CN=(?&amp;lt;DNmanquante&amp;gt;[^,]+)[^']+'\n(- CODE \(serial : (?P&amp;lt;CRLmanquante&amp;gt;\d+)\) error.\n-+\n)+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Event example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CC :' 223' de DN : 'CN=XXX 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- CODE (serial : 1234) error.
---------------------------------------------------------
- CODE (serial : 5676) error.
---------------------------------------------------------
- CODE (serial : 5677) error.
---------------------------------------------------------
- CODE (serial : 5678) error.
---------------------------------------------------------
- CODE (serial : 5679) error.
---------------------------------------------------------
CC :' 224' de DN : 'CN=YYY 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get XXX 2025:1234,XXX 2025:5678...etc like a tree with 1 or more branches.&lt;/P&gt;

&lt;P&gt;The problem is it returns only last match : 5679&lt;/P&gt;

&lt;P&gt;Thanks a lot.&lt;/P&gt;

&lt;P&gt;Regex101 link : &lt;A href="https://regex101.com/r/M96VAN/2"&gt;https://regex101.com/r/M96VAN/2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 15:04:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379256#M111129</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-19T15:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379257#M111130</link>
      <description>&lt;P&gt;Hi...your rex query got damaged, since the answer portal can not accept those.. &lt;BR /&gt;
after writing your rex query, select it and then do "control-k" (to make it as a "code").. &lt;BR /&gt;
or , use backticks before and after your rex (like.. &lt;CODE&gt;| rex field=_raw ..&lt;/CODE&gt;) ... &lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 15:38:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379257#M111130</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-09-19T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379258#M111131</link>
      <description>&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 15:55:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379258#M111131</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-19T15:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379259#M111132</link>
      <description>&lt;P&gt;@realsplunk&lt;BR /&gt;
Can you please try following search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex max_match=0 field=_raw "CC :' \d+' de DN : 'CN=(?&amp;lt;CN&amp;gt;[^,]+)[^']*'" | rex max_match=0 field=_raw "(- CODE \(serial : (?P&amp;lt;CODE&amp;gt;\d+)\) error)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here I have used separate rex for CN &amp;amp; Code.&lt;/P&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="CC :' 223' de DN : 'CN=XXX 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 - CODE (serial : 1234) error.
 ---------------------------------------------------------
 - CODE (serial : 5676) error.
 ---------------------------------------------------------
 - CODE (serial : 5677) error.
 ---------------------------------------------------------
 - CODE (serial : 5678) error.
 ---------------------------------------------------------
 - CODE (serial : 5679) error.
 ---------------------------------------------------------
 CC :' 224' de DN : 'CN=YYY 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'" | rex max_match=0 field=_raw "CC :' \d+' de DN : 'CN=(?&amp;lt;CN&amp;gt;[^,]+)[^']*'" | rex max_match=0 field=_raw "(- CODE \(serial : (?P&amp;lt;CODE&amp;gt;\d+)\) error)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updated Ans:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex max_match=0 field=_raw "(?&amp;lt;data&amp;gt;.*[^\n]+)" 
| mvexpand data 
| table data 
| rex max_match=0 field=data "CC :' \d+' de DN : 'CN=(?&amp;lt;CN&amp;gt;[^,]+)[^']*'" 
| rex max_match=0 field=data "(- CODE \(serial : (?P&amp;lt;CODE&amp;gt;\d+)\) error)" 
| filldown CN 
| search CODE=* | table CN CODE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="CC :' 223' de DN : 'CN=XXX 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  - CODE (serial : 1234) error.
  ---------------------------------------------------------
  - CODE (serial : 5676) error.
  ---------------------------------------------------------
  - CODE (serial : 5677) error.
  ---------------------------------------------------------
  - CODE (serial : 5678) error.
  ---------------------------------------------------------
  - CODE (serial : 5679) error.
  ---------------------------------------------------------
  CC :' 224' de DN : 'CN=YYY 2025, ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   - CODE (serial : 1234) error.
  ---------------------------------------------------------
  - CODE (serial : 5676) error.
  ---------------------------------------------------------
  - CODE (serial : 5677) error.
  ---------------------------------------------------------" 
| rex max_match=0 field=_raw "(?&amp;lt;data&amp;gt;.*[^\n]+)" 
| mvexpand data 
| table data 
| rex max_match=0 field=data "CC :' \d+' de DN : 'CN=(?&amp;lt;CN&amp;gt;[^,]+)[^']*'" 
| rex max_match=0 field=data "(- CODE \(serial : (?P&amp;lt;CODE&amp;gt;\d+)\) error)" 
| filldown CN 
| search CODE=* | table CN CODE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:43:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379259#M111132</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-19T16:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379260#M111133</link>
      <description>&lt;P&gt;Hi Kamlesh, thanks however this way I can't associate CN with CODE accordingly.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 09:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379260#M111133</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-20T09:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379261#M111134</link>
      <description>&lt;P&gt;@realsplunk&lt;/P&gt;

&lt;P&gt;quick question.&lt;/P&gt;

&lt;P&gt;The event you provided will come in a single event or individual event? &lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 04:23:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379261#M111134</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-21T04:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379262#M111135</link>
      <description>&lt;P&gt;It's a multiline single event, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 07:04:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379262#M111135</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-21T07:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379263#M111136</link>
      <description>&lt;P&gt;Dirty solution :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CC :' \d+' de DN : 'CN=(?&amp;lt;CN&amp;gt;[^,]+)[^']+'\n- CODE \(serial : (?P&amp;lt;CODE&amp;gt;\d+)\) error.\n-+\n- CODE \(serial : (?P&amp;lt;CODE2&amp;gt;\d+)\) error.\n-+\n- CODE \(serial : (?P&amp;lt;CODE3&amp;gt;\d+)\) error.\n-+\n- CODE \(serial : (?P&amp;lt;CODE4&amp;gt;\d+)\) error.\n-+\n- CODE \(serial : (?P&amp;lt;CODE5&amp;gt;\d+)\) error.\n-+\n
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 13:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379263#M111136</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-21T13:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379264#M111137</link>
      <description>&lt;P&gt;@realsplunk&lt;/P&gt;

&lt;P&gt;See my Updated ans. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I hope I will work for you.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 16:32:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379264#M111137</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-21T16:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379265#M111138</link>
      <description>&lt;P&gt;Congratulations, it works, good method &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 10:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379265#M111138</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2018-09-24T10:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379266#M111139</link>
      <description>&lt;P&gt;Great. &lt;BR /&gt;
Glad to help you.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Happy Splunking&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 10:18:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379266#M111139</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-24T10:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Will you help me create a regex to extract one or more lines with same heading in a single event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379267#M111140</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; , could you please guide what the regex would have been if we were to want to extract only the first occurrence of the  (or &lt;CODE&gt;) from the results? Should 'max_match' = 1 in that case? Thanks!&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:10:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Will-you-help-me-create-a-regex-to-extract-one-or-more-lines/m-p/379267#M111140</guid>
      <dc:creator>rey123</dc:creator>
      <dc:date>2020-09-30T02:10:16Z</dc:date>
    </item>
  </channel>
</rss>

