<?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: Specifying two regular expressions in a single search query using rex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34447#M7421</link>
    <description>&lt;P&gt;This is correct. For an event like;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;timestamp [blah] AAA:BBB:CCC DDD:EEE:FFF&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;where you wish to extract 'blah' and 'EEE', you can write a regex that will get them in one go;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;...| rex "\[(?&amp;lt;first&amp;gt;[^\]]+)\]\s\S+\s\w:(?&amp;lt;second&amp;gt;\w+):\w+"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However some care might be required - if the messages in a log are formatted differently, so that for some events e.g. the &lt;CODE&gt;second&lt;/CODE&gt; field can't be matched, the &lt;CODE&gt;rex&lt;/CODE&gt; statement as a whole will fail, and neither &lt;CODE&gt;first&lt;/CODE&gt; nor &lt;CODE&gt;second&lt;/CODE&gt; will be extracted for that event.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2013 10:37:36 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-08-14T10:37:36Z</dc:date>
    <item>
      <title>Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34445#M7419</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have SharePoint logs and  in that there is a field called message.From the message field i have extracted exceptions using regular expressions.Here for extracting three exceptions i have used one regular expression and for other two i have used different regex.&lt;BR /&gt;
The search queries used for those two different regex are :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="sharepoint" | rex field=message "(?i)\b exception\b:\s(?P&amp;lt;FieldIdentifier&amp;gt;[^\)]+Exception)\:" | table FieldIdentifier
host="sharepoint" | rex field=message "(?&amp;lt;=[Errorlfailed]\: )(?P&amp;lt;FieldIdentifier1&amp;gt;[^\)]+Exception:)" |  table FieldIdentifier
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here i want to have single search query including both the regex.How can i write this in rex command .Tried with OR command  but that din't worked.So pls help with the query.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 09:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34445#M7419</guid>
      <dc:creator>ChhayaV</dc:creator>
      <dc:date>2013-08-14T09:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34446#M7420</link>
      <description>&lt;P&gt;If the regex statements are matching the required field values, you can write it in a single statement.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="sharepoint" | rex field=message "(?i)\b exception\b:\s(?P&amp;lt;Field1&amp;gt;[^\)]+Exception)\:"(?&amp;lt;=[Errorlfailed]\: )(?P&amp;lt;Field2&amp;gt;[^\)]+Exception:)" |  table Field1,Field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also do it in the splunk UI field extraction window&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 09:38:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34446#M7420</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-14T09:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34447#M7421</link>
      <description>&lt;P&gt;This is correct. For an event like;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;timestamp [blah] AAA:BBB:CCC DDD:EEE:FFF&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;where you wish to extract 'blah' and 'EEE', you can write a regex that will get them in one go;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;...| rex "\[(?&amp;lt;first&amp;gt;[^\]]+)\]\s\S+\s\w:(?&amp;lt;second&amp;gt;\w+):\w+"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However some care might be required - if the messages in a log are formatted differently, so that for some events e.g. the &lt;CODE&gt;second&lt;/CODE&gt; field can't be matched, the &lt;CODE&gt;rex&lt;/CODE&gt; statement as a whole will fail, and neither &lt;CODE&gt;first&lt;/CODE&gt; nor &lt;CODE&gt;second&lt;/CODE&gt; will be extracted for that event.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 10:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34447#M7421</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-08-14T10:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34448#M7422</link>
      <description>&lt;P&gt;Hi linu1988,&lt;BR /&gt;
I tried with the way you have suggested but its not working.Saying error in rex command.&lt;BR /&gt;
Actually i tried with the pipe(|) command which is not showing any error in the regex(no desirable output).&lt;BR /&gt;
Tried query is :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host="sharepoint" | rex field=message "(?&amp;lt;=[Errorlfailed]\: )(?P&amp;lt;Field1&amp;gt;[^\)]+Exception:)|(?i)\b exception\b:\s(?P&amp;lt;Field2&amp;gt;[^\)]+Exception)\:" | table Field1 Field2&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Here its only displaying the result for Field1.Field2 values are coming blank.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 11:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34448#M7422</guid>
      <dc:creator>ChhayaV</dc:creator>
      <dc:date>2013-08-14T11:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34449#M7423</link>
      <description>&lt;P&gt;Also one more thing is i want Field1 and Field2 values to be captured in a single field i.e.,values of Field1 and Field2 should captured as a single field say "NewField"&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 11:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34449#M7423</guid>
      <dc:creator>ChhayaV</dc:creator>
      <dc:date>2013-08-14T11:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34450#M7424</link>
      <description>&lt;P&gt;If you're going to use these extractions for anything else but just the odd search here and there you really should move them into props.conf / transforms.conf instead of having them inline in your searches.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 11:56:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34450#M7424</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-08-14T11:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34451#M7425</link>
      <description>&lt;P&gt;Chhaya, if you are having problem with the search you can actually use the props.conf/transforms.conf as Ayn has suggested. I don't have the log with me so cant create the perfect matching. &lt;/P&gt;

&lt;P&gt;You can also do |rex ..&lt;FIELD1&gt;.. |rex ..&lt;FIELD2&gt;. |eval Newfield=field1." ".field2 OR directly get the fields and concatenate extracted from props.conf. Hope it clarifies..&lt;/FIELD2&gt;&lt;/FIELD1&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 13:30:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34451#M7425</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-14T13:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34452#M7426</link>
      <description>&lt;P&gt;The error is probably related to fact that you have a pipe character in the rex. Try to escape it with a backslash, otherwise it may be interpreted as part of the search query.&lt;/P&gt;

&lt;P&gt;also, should it say 'Errorlfailed'? you don't want '(Error|Failed)'? Escape as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2013 14:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34452#M7426</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-08-14T14:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34453#M7427</link>
      <description>&lt;P&gt;Hi linu1988,&lt;BR /&gt;
i just wanted to do it through Splunk web.&lt;BR /&gt;
Here i have provided the sample log entries&lt;BR /&gt;
" &lt;A href="http://answers.splunk.com/answers/98772/field-extraction-using-regex-command"&gt;http://answers.splunk.com/answers/98772/field-extraction-using-regex-command&lt;/A&gt; "&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 06:47:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34453#M7427</guid>
      <dc:creator>ChhayaV</dc:creator>
      <dc:date>2013-08-16T06:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34454#M7428</link>
      <description>&lt;P&gt;Hello ChhayaV,&lt;BR /&gt;
The log doesn't have anything to match for the second regex so i can't try with it. The first regex matches the fields which you require.&lt;/P&gt;

&lt;P&gt;If you want to do on UI, you can do it one field at a time after that save the field or ignore the matches which are not required.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 08:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34454#M7428</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-08-16T08:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Specifying two regular expressions in a single search query using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34455#M7429</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Finally i came up with the working solution and the search query is as follows :&lt;BR /&gt;
host="sharepoint" | rex field=message "(?i)\b exception\b:\s(?P&lt;FIELD1&gt;[^)]+Exception):" |rename Field1 as output | append [search host="sharepoint" | rex field=message "(?&amp;lt;=[Errorlfailed]: )(?P&lt;FIELD2&gt;[^)]+Exception:)" | &lt;BR /&gt;
rename Field2 as output] | table output&lt;/FIELD2&gt;&lt;/FIELD1&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2013 09:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Specifying-two-regular-expressions-in-a-single-search-query/m-p/34455#M7429</guid>
      <dc:creator>ChhayaV</dc:creator>
      <dc:date>2013-08-16T09:00:24Z</dc:date>
    </item>
  </channel>
</rss>

