<?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 print 7th word of a one if a particular condition is met in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458807#M129548</link>
    <description>&lt;P&gt;Dedup worked. Thanks @kamlesh_vaghela &lt;/P&gt;</description>
    <pubDate>Fri, 23 Aug 2019 07:09:30 GMT</pubDate>
    <dc:creator>saranyaa21</dc:creator>
    <dc:date>2019-08-23T07:09:30Z</dc:date>
    <item>
      <title>Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458802#M129543</link>
      <description>&lt;P&gt;Hi , &lt;/P&gt;

&lt;P&gt;below is the sample data : &lt;/P&gt;

&lt;P&gt;12:10:32,946 INFO  [class_name] [IP address] [id1]  [-] [null,null,null,null,null,null,pincode] Logged in. &lt;BR /&gt;
12:10:32,968 INFO  [class_name] [IP address] [id1]  [-] [name,id,location,street,state,country,pincode] Performing activity.&lt;/P&gt;

&lt;P&gt;I'm trying to print the class name if 6th word is [-] and 7th word contains null values in it.&lt;/P&gt;

&lt;P&gt;I'm using the following regex to do so: &lt;BR /&gt;
rex field=_raw "(^(?:\S+\s+){2})(?&amp;lt;"Class_name"&amp;gt;(\S+))" |rex field=_raw "(?&amp;lt;"Details"&amp;gt;(?&amp;lt;=[-]\s[null).*pincode])"'&lt;/P&gt;

&lt;P&gt;My challenge here: &lt;BR /&gt;
This regex only captures the class_name and null,null,null,null,null,null,pincode . Actually, the same class has already printed the details for the same id id1 in a different place. &lt;/P&gt;

&lt;P&gt;How should I correct my regular expression, in order to check, if the class has already printed the details, and to skip that class from the collection of empty details printing class list . &lt;/P&gt;

&lt;P&gt;Thanks in advance . &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458802#M129543</guid>
      <dc:creator>saranyaa21</dc:creator>
      <dc:date>2020-09-30T01:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458803#M129544</link>
      <description>&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex field=_raw "(^(?:\S+\s+){2})\[(?&amp;lt;Class_name&amp;gt;(\S+))\]"  |rex field=_raw "(?&amp;lt;Details&amp;gt;(\[-\]\s\[null.*pincode]))" | dedup Class_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval d="12:10:32,946 INFO [class_name] [IP address] [id1] [-] [null,null,null,null,null,null,pincode] Logged in.||12:10:32,968 INFO [class_name] [IP address] [id1] [-] [name,id,location,street,state,country,pincode] Performing activity." | eval d=split(d,"||") | mvexpand d | eval _raw=d | fields _raw | rex field=_raw "(^(?:\S+\s+){2})\[(?&amp;lt;Class_name&amp;gt;(\S+))\]"  |rex field=_raw "(?&amp;lt;Details&amp;gt;(\[-\]\s\[null.*pincode]))" | dedup Class_name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 05:14:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458803#M129544</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-22T05:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458804#M129545</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; , &lt;/P&gt;

&lt;P&gt;Your sample search works, as expected. But how do I use my search, to combine different pieces of logs as you have done in &lt;/P&gt;

&lt;P&gt;| makeresults | eval d="12:10:32,946 INFO [class_name] [IP address] [id1] [-] [null,null,null,null,null,null,pincode] Logged in.||12:10:32,968 INFO [class_name] [IP address] [id1] [-] [name,id,location,street,state,country,pincode] Performing activity." | eval d=split(d,"||") | mvexpand d | eval _raw=d | fields _raw | rex field=_raw "(^(?:\S+\s+){2})[(?(\S+))]"  |rex field=_raw "(?([-]\s[null.*pincode]))" | dedup Class_name&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458804#M129545</guid>
      <dc:creator>saranyaa21</dc:creator>
      <dc:date>2020-09-30T01:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458805#M129546</link>
      <description>&lt;P&gt;In this query below since two line, it was explicitly mentioned for comparison. But how do I compare huge logs when I don't know what will be the log entry. &lt;/P&gt;

&lt;P&gt;| makeresults | eval d="12:10:32,946 INFO [class_name] [IP address] [id1] [-] [null,null,null,null,null,null,pincode] Logged in.||12:10:32,968 INFO [class_name] [IP address] [id1] [-] [name,id,location,street,state,country,pincode] Performing activity." | eval d=split(d,"||") | mvexpand d | eval _raw=d | fields _raw | rex field=_raw "(^(?:\S+\s+){2})[(?(\S+))]"  |rex field=_raw "(?([-]\s[null.*pincode]))" | dedup Class_name&lt;/P&gt;

&lt;P&gt;should I try something like, &lt;/P&gt;

&lt;P&gt;| makeresults | eval d="&lt;STRONG&gt;sourcetype=serverlog||sourcetype=serverlog&lt;/STRONG&gt; | eval d=split(d,"||") | mvexpand d | eval _raw=d | fields _raw | rex field=_raw "(^(?:\S+\s+){2})[(?(\S+))]"  |rex field=_raw "(?([-]\s[null.*pincode]))" | dedup Class_name&lt;/P&gt;

&lt;P&gt;How should I pass the raw field here , the entire logs here ?! &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:51:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458805#M129546</guid>
      <dc:creator>saranyaa21</dc:creator>
      <dc:date>2020-09-30T01:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458806#M129547</link>
      <description>&lt;P&gt;@saranyaa21 &lt;/P&gt;

&lt;P&gt;You have to use below portion of &lt;CODE&gt;search&lt;/CODE&gt; with your event, Like if your events are in &lt;CODE&gt;abc&lt;/CODE&gt; index and &lt;CODE&gt;xyz&lt;/CODE&gt; sourcetype the your search should be like below  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc sourcetype=xyz  | rex field=_raw "(^(?:\S+\s+){2})[(?(\S+))]" |rex field=_raw "(?([-]\s[null.*pincode]))" | dedup Class_name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 06:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458806#M129547</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-22T06:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458807#M129548</link>
      <description>&lt;P&gt;Dedup worked. Thanks @kamlesh_vaghela &lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 07:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458807#M129548</guid>
      <dc:creator>saranyaa21</dc:creator>
      <dc:date>2019-08-23T07:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458808#M129549</link>
      <description>&lt;P&gt;Gald to help you @saranyaa21.  Can you please accept this answer to close this question?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 07:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458808#M129549</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-23T07:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to print 7th word of a one if a particular condition is met</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458809#M129550</link>
      <description>&lt;P&gt;done Kamlesh&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 09:35:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-print-7th-word-of-a-one-if-a-particular-condition-is/m-p/458809#M129550</guid>
      <dc:creator>saranyaa21</dc:creator>
      <dc:date>2019-08-23T09:35:36Z</dc:date>
    </item>
  </channel>
</rss>

