<?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: Extract information via regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161998#M45822</link>
    <description>&lt;P&gt;Hi sbsbb,&lt;/P&gt;

&lt;P&gt;Indeed : is the correct, has error of typing, sorry!&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2013 17:59:22 GMT</pubDate>
    <dc:creator>rafamss</dc:creator>
    <dc:date>2013-12-02T17:59:22Z</dc:date>
    <item>
      <title>Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161992#M45816</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I need some help to split the field below:&lt;/P&gt;

&lt;P&gt;xyu_0987|123456:123456|123456:123456,&lt;/P&gt;

&lt;P&gt;before the first pipeline(xyz_9807) displays the information about one rule;&lt;BR /&gt;
after the first pipeline(|93830:09383) displays the information about alerts rules;&lt;BR /&gt;
after the second pipeline(|093732:827332) displays information about denied rules.&lt;/P&gt;

&lt;P&gt;The second point is that each rule is segmented by  " : ", how i split the fields in order to keep this format: Remembering that segmented rule can be repeat more times, and each rule must be in fields separated.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Rule       Alerts Rule              Denied Rule 
           Rule 1 : Rule 2          Rule 1 : Rule 2
xyu_0987   123456 : 123456          123456 : 123456
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you help me ?&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Rafael Martins&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 13:46:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161992#M45816</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-02T13:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161993#M45817</link>
      <description>&lt;P&gt;"Remembering that segmented rule can be repeat more times, and each rule must be in fields separated". &lt;BR /&gt;
Can you provide some example of this as well?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 14:14:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161993#M45817</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-02T14:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161994#M45818</link>
      <description>&lt;P&gt;For making my tries with splunk regex, I use the program Kodos, that use the same synthax...&lt;/P&gt;

&lt;P&gt;I would suggest you something like (I'm not good at regex, but mostly achieve what I want &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(?P&amp;lt;Rule&amp;gt;.*)\|(?P&amp;lt;Alert1&amp;gt;.*):(?P&amp;lt;Alert2&amp;gt;.*)\|(?P&amp;lt;Denied1&amp;gt;.*):(?P&amp;lt;Denied2&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the number of Rules between the pipes is unknown, than I would try first to extract AlertString, DeniedString, and then extract the Rules as Multivalue Field you could mvexpand :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "(?P&amp;lt;Rule&amp;gt;.*)\|(?P&amp;lt;AlertString&amp;gt;.*)\|(?P&amp;lt;DeniedString&amp;gt;.*)
| rex max_match=0 field=AlertString "(?P&amp;lt;AlertRules&amp;gt;[regex to split Rules])"
| rex max_match=0 field=AlertString "(?P&amp;lt;DeniedRules&amp;gt;[regex to split Rules])"
| mvexpand AlertRules | fields - AlertString
| mvexpand DeniedRules | fields - DeniedString
| table *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2013 15:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161994#M45818</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-02T15:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161995#M45819</link>
      <description>&lt;P&gt;Sure somesoni2.&lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
For the first pipeline, we have |987654:1098762:098675, in this case, we have three distinct  values for alert rules.&lt;BR /&gt;
For the second pipeline, we have |092822:098271, in this case, we have two distinct values for denied rules.&lt;/P&gt;

&lt;P&gt;Do you understand ?&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Rafael Martins&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 15:48:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161995#M45819</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-02T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161996#M45820</link>
      <description>&lt;P&gt;Hi sbsbb,&lt;/P&gt;

&lt;P&gt;I tried this solution, but without sucess. Take a look in this line of the log. I tried to use that refex that you passed but don't work. The format of log is access_combined_wcookie&lt;/P&gt;

&lt;P&gt;192.168.0.1 - - [28/Nov/2013:02:09:24 +0000] "GET /127.0.0.1/icon.png HTTP/1.1" 200 3288 "-" "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0" "-" "rule_1234|098765?098765|123456?123456"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:23:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161996#M45820</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2020-09-28T15:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161997#M45821</link>
      <description>&lt;P&gt;Of course you input is different, than the example... you have ? in place of :&lt;/P&gt;

&lt;P&gt;(?P&lt;RULE&gt;rule_.&lt;EM&gt;)|(?P&lt;ALERT1&gt;.&lt;/ALERT1&gt;&lt;/EM&gt;)\?(?P&lt;ALERT2&gt;.&lt;EM&gt;)|(?P&lt;DENIED1&gt;.&lt;/DENIED1&gt;&lt;/EM&gt;)\?(?P&lt;DENIED2&gt;.*)"&lt;/DENIED2&gt;&lt;/ALERT2&gt;&lt;/RULE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 16:49:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161997#M45821</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-02T16:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161998#M45822</link>
      <description>&lt;P&gt;Hi sbsbb,&lt;/P&gt;

&lt;P&gt;Indeed : is the correct, has error of typing, sorry!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 17:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161998#M45822</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-02T17:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161999#M45823</link>
      <description>&lt;P&gt;If you have already extracted the field from your log which has rules information, say ruleInfo, the following works.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search with ruleInfo extracted|rex field=ruleInfo max_match=0 "(?P&amp;lt;Rule&amp;gt;.*)\|(?P&amp;lt;AlertString&amp;gt;.*)\|(?P&amp;lt;DeniedString&amp;gt;.*)" | rex max_match=0 field=AlertString "(?P&amp;lt;AlertRules&amp;gt;[^:]+)" | rex max_match=0 field=DeniedString "(?P&amp;lt;DeniedRules&amp;gt;[^:]+)" | table Rule, AlertRules, DeniedRules | mvexpand AlertRules | mvexpand DeniedRules | mvcombine delim=":"  AlertRules | mvcombine delim=":" DeniedRules | nomv DeniedRules
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output is like below:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Rule          AlertRules                     DeniedRules     
gijo_0987     10856:123456                   123326:133456                     
sms_0987      123456:147556:1237776:28856    10056:126656 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2013 18:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/161999#M45823</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-02T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162000#M45824</link>
      <description>&lt;P&gt;Hi sbsbb,&lt;/P&gt;

&lt;P&gt;I tried to use your code, but in some cases the regex don't work correctly, so I changed the regex to below:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex max_match=0 "(?P&amp;lt;Rule&amp;gt;.*)\|(?P&amp;lt;AlertString&amp;gt;.*)\|(?P&amp;lt;DeniedString&amp;gt;.*)" | rex max_match=0 field=AlertString "(?P&amp;lt;AlertRules&amp;gt;......:*)" | rex max_match=0 field=AlertString "(?P&amp;lt;AlertRules&amp;gt;......:*)" | rex max_match=0 field=AlertRules "(?P&amp;lt;AlertRule&amp;gt;......_*)" | mvexpand AlertRule | fields - AlertString | rex max_match=0 field=DeniedString "(?P&amp;lt;DeniedRules&amp;gt;......:*)" | rex max_match=0 field=DeniedRules "(?P&amp;lt;DeniedRule&amp;gt;......_*)" | mvexpand DeniedRule | fields - DeniedString&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;But when I put the regex separately,  it works, when I put the regex together, both doesn't  works.&lt;/P&gt;

&lt;P&gt;What do you think ?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2013 19:16:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162000#M45824</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-03T19:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162001#M45825</link>
      <description>&lt;P&gt;Hi somesoni2,&lt;/P&gt;

&lt;P&gt;I need that fields are separately by AlertRules, so for the  AlertRules, each rule is separately by ":". The regex to below is correct, but doesn't works together.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2013 19:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162001#M45825</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-03T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract information via regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162002#M45826</link>
      <description>&lt;P&gt;Hi sbsbb,&lt;/P&gt;

&lt;P&gt;Your solution code worked fine, but I had to add some pieces. Please look my question below.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2013 19:26:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-information-via-regex/m-p/162002#M45826</guid>
      <dc:creator>rafamss</dc:creator>
      <dc:date>2013-12-03T19:26:57Z</dc:date>
    </item>
  </channel>
</rss>

