<?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: Help with regex with two different type events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472836#M133089</link>
    <description>&lt;P&gt;Hi vrmandadi,&lt;BR /&gt;
you could try to use two regexes to extract fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "EDT\s\d*\s(?&amp;lt;USERNAME&amp;gt;[^\s]+)\s*(?&amp;lt;STATUS&amp;gt;.*)\s+(?&amp;lt;ROLE&amp;gt;[^ ]+)$"
| rex field=STATUS "(?&amp;lt;STATUS1&amp;gt;.*)\s+(?&amp;lt;expity_date&amp;gt;\d+-\w+-\d+)"
| eval STATUS=coalesce(STATUS1, STATUS)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second regex runs with events with expiry date and the second one with events without it.&lt;BR /&gt;
You can test the first regex in &lt;A href="https://regex101.com/r/oNrmd0/1"&gt;https://regex101.com/r/oNrmd0/1&lt;/A&gt; and the second one in &lt;A href="https://regex101.com/r/oNrmd0/2"&gt;https://regex101.com/r/oNrmd0/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2019 14:37:31 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-09-05T14:37:31Z</dc:date>
    <item>
      <title>Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472833#M133086</link>
      <description>&lt;P&gt;Hello I have the below sample events &lt;BR /&gt;
Thu Sep  5 10:00:02 EDT 2019 XDB                            EXPIRED &amp;amp; LOCKED               28-SEP-11                      CTXAPP&lt;/P&gt;

&lt;P&gt;Thu Sep  5 10:00:02 EDT 2019 VWEinsnte3345                  LOCKED                                                        GPW_READ&lt;BR /&gt;
Thu Sep  5 10:00:02 EDT 2019 SK_RYT                       LOCKED(TIMED)                                                 CDS_SELECT_ALL&lt;/P&gt;

&lt;P&gt;I want to extract XDB , VWEinsnte3345 ,SK_RYT AS USERNAME  and EXPIRED &amp;amp; LOCKED , LOCKED , LOCKED(TIMED) as status , 28-SEP-11 as expiry date(this field is  not there for all events) and  CTXAPP , GPW_READ , CDS_SELECT_ALL as ROLE &lt;/P&gt;

&lt;P&gt;Below is the regex I am using but this is only extracting for event 2 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EDT\s\d*\s(?&amp;lt;USERNAME&amp;gt;[^\s]+)\s*(?&amp;lt;STATUS&amp;gt;[^ ]+)\s*(?&amp;lt;ROLE&amp;gt;[^ ]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:04:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472833#M133086</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-30T02:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472834#M133087</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EDT\s\d*\s(?&amp;lt;USERNAME&amp;gt;[^\s]+)\s*(?&amp;lt;STATUS&amp;gt;\w+( &amp;amp; \w+)?)\s*(?&amp;lt;EXPIRY&amp;gt;\d+-[A-Z]+-\d+)?\s*(?&amp;lt;ROLE&amp;gt;[A-Za-z0-9_-]+)  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;regex101.com is your friend.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/ojcpz7/1"&gt;https://regex101.com/r/ojcpz7/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 14:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472834#M133087</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2019-09-05T14:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472835#M133088</link>
      <description>&lt;P&gt;Hello @DalJeanis  I tried your regex but it did not work .I did try that in regex101 but it is not capturing everything for EXPIRY the values are 28-SEP-1 and ROLE has 1 which should be 28-SEP-11 and CTXAPP respectively .&lt;BR /&gt;
The same with event 2 the status has value LOCKE and ROLE has D &lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 14:35:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472835#M133088</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2019-09-05T14:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472836#M133089</link>
      <description>&lt;P&gt;Hi vrmandadi,&lt;BR /&gt;
you could try to use two regexes to extract fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "EDT\s\d*\s(?&amp;lt;USERNAME&amp;gt;[^\s]+)\s*(?&amp;lt;STATUS&amp;gt;.*)\s+(?&amp;lt;ROLE&amp;gt;[^ ]+)$"
| rex field=STATUS "(?&amp;lt;STATUS1&amp;gt;.*)\s+(?&amp;lt;expity_date&amp;gt;\d+-\w+-\d+)"
| eval STATUS=coalesce(STATUS1, STATUS)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second regex runs with events with expiry date and the second one with events without it.&lt;BR /&gt;
You can test the first regex in &lt;A href="https://regex101.com/r/oNrmd0/1"&gt;https://regex101.com/r/oNrmd0/1&lt;/A&gt; and the second one in &lt;A href="https://regex101.com/r/oNrmd0/2"&gt;https://regex101.com/r/oNrmd0/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 14:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472836#M133089</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-05T14:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472837#M133090</link>
      <description>&lt;P&gt;is that your entire event? if not then could pls share the entire event?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 15:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472837#M133090</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-09-05T15:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex with two different type events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472838#M133091</link>
      <description>&lt;P&gt;Thanks Much&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 17:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-with-two-different-type-events/m-p/472838#M133091</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2019-09-06T17:45:48Z</dc:date>
    </item>
  </channel>
</rss>

