<?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: Rex to extract text that ends with either one of multiple words in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432609#M123608</link>
    <description>&lt;P&gt;Sorry  this will not work, as the contents I want to extract will also contain "double quote". Sorry I forgot to mentioned in original post (I have updated it now)&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jan 2019 09:47:31 GMT</pubDate>
    <dc:creator>Cbr1sg</dc:creator>
    <dc:date>2019-01-30T09:47:31Z</dc:date>
    <item>
      <title>Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432605#M123604</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;
I have data like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;reason="abc";appName=....
reason="xyz";ERServer=...
reason="dfg",ClientBob=...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to extract only &lt;STRONG&gt;abc&lt;/STRONG&gt;,&lt;STRONG&gt;xyz&lt;/STRONG&gt; and &lt;STRONG&gt;dfg&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;note that abc, xyz and dfg might contain character "&lt;STRONG&gt;;&lt;/STRONG&gt;" or "&lt;STRONG&gt;,&lt;/STRONG&gt;"  or &lt;STRONG&gt;"="&lt;/STRONG&gt; or &lt;STRONG&gt;doublequotes&lt;/STRONG&gt; or &lt;STRONG&gt;single quote&lt;/STRONG&gt;.&lt;BR /&gt;
Basically it is really dynamic and can contain &lt;STRONG&gt;any&lt;/STRONG&gt; kind of character. The only consistent pattern are the ending words as mentioned above&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 02:39:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432605#M123604</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-30T02:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432606#M123605</link>
      <description>&lt;P&gt;do they always end in a double quotes?&lt;BR /&gt;
also, looks like you have key value pairs using "=" and separated with ";" OR ","&lt;BR /&gt;
take a look at the &lt;CODE&gt;extract&lt;/CODE&gt; command&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 02:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432606#M123605</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-01-30T02:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432607#M123606</link>
      <description>&lt;P&gt;Here is a run anywhere search that shows the &lt;CODE&gt;rex&lt;/CODE&gt; command that will pick out the field as you have provided the data for in your question:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | 
eval data="reason=\"abc\";appName=....
 reason=\"xyz\";ERServer=...
 reason=\"dfg\",ClientBob=..." | 
 makemv delim="
 " data | 
 rex field=data "reason=\"(?&amp;lt;reason&amp;gt;[^\"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure if this meets your requirements, but it can be run in any Splunk search bar and produce the results you have requested. The last line is the only one that is really doing any of the work for that purpose. The other lines are only setting up the data that simulates the events as portrayed above.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 02:57:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432607#M123606</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2019-01-30T02:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432608#M123607</link>
      <description>&lt;P&gt;This will not work, as the contents I want to extract will also contain ";" OR "," (as I mentioned in original post)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 09:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432608#M123607</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-30T09:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432609#M123608</link>
      <description>&lt;P&gt;Sorry  this will not work, as the contents I want to extract will also contain "double quote". Sorry I forgot to mentioned in original post (I have updated it now)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 09:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432609#M123608</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-30T09:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432610#M123609</link>
      <description>&lt;P&gt;If the first and last charakter for the &lt;CODE&gt;reason&lt;/CODE&gt; field always will be a double quote &lt;STRONG&gt;and contains no equal-sign&lt;/STRONG&gt;, you could try to use a greedy match like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=data "reason=\"(?&amp;lt;reason&amp;gt;.*)\"\S+="
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This reges will try to match as many charakters as possible until the last double-quote which then is followed by non-whitespace-chars and a equal-sign.&lt;/P&gt;

&lt;P&gt;For my set of test data this worked perfectly, even if the reason contained one or more commas, semicolons or double quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 12:25:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432610#M123609</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-01-30T12:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432611#M123610</link>
      <description>&lt;P&gt;As long as there is something like &lt;CODE&gt;;wordchars=&lt;/CODE&gt; after the quoted data you want to extract, the following will probably work for you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | 
 eval data="reason=\"a\\\"b\"c\";appName=....
  reason=\"x;yz\";ERServer=...
  reason=\"df,g\",ClientBob=..." | 
  makemv delim="
  " data | 
  rex field=data "reason=\"(?&amp;lt;reason&amp;gt;.*?)\"[;,]\w+="
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Jan 2019 16:43:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432611#M123610</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2019-01-30T16:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432612#M123611</link>
      <description>&lt;P&gt;I' m really really sorry, the text i want to extract also contains equal sign so this won't work as well. My bad, my description about the issue was not clear enough. I updated original post with full range of character that might be included in the text i want to extract&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 02:01:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432612#M123611</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-31T02:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432613#M123612</link>
      <description>&lt;P&gt;I' m really really sorry, the text i want to extract also contains equal sign so this won't work as well. My bad, my description about the issue was not clear enough. I updated original post with full range of character that might be included in the text i want to extract&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 02:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432613#M123612</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-31T02:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432614#M123613</link>
      <description>&lt;P&gt;Unless the double quotes &lt;EM&gt;inside&lt;/EM&gt; the field are escaped (for example with a backslash) you are pretty much screwed because there doesn't seem to be enough regularity to the string to make extracting it properly an option. If you give an exact example (doesn't have to contain real data, just valid data with all the possibilities, so clean it up for public consumption), it might be possible to help you on this.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 02:42:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432614#M123613</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2019-01-31T02:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432615#M123614</link>
      <description>&lt;P&gt;Yes you're right that makes sense. 3 examples of the data are as below:&lt;/P&gt;

&lt;P&gt;reason="AAABBB";Client="112233",source="aassdd";server="IIHHSS";appName="ooiiuu"&lt;BR /&gt;
reason="NNCCSA";Network="asdasasd";NextHop="asda",data="asdasasd";Subnet="10.12.12.12,24";RemoteIP="12.12.12.12,mask=255.255.255.0";ClientBob="aabbcc"&lt;BR /&gt;
reason="dgfsdd";External="asdasas";Policy="asdasasda";Domain="asdasdas";ClientVersion=12312312321";Path="hop1=1213,hop2=23432,hop3=23432,hop4=2343";ERServer=asdadasda"&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 05:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432615#M123614</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-01-31T05:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432616#M123615</link>
      <description>&lt;P&gt;You can try this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your index | rex field=_raw "reason\=.(?P&amp;lt;field_name&amp;gt;[^\.]\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Jan 2019 09:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432616#M123615</guid>
      <dc:creator>vinod94</dc:creator>
      <dc:date>2019-01-31T09:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432617#M123616</link>
      <description>&lt;P&gt;Okay, given the examples you provided for @cpetterborg above, and your statement that only the 3 mentioned keywords above could mark the end fo your event, a RegEx that would match looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; rex field=data "reason=\"(?&amp;lt;reason&amp;gt;.*)\".(?:appName|ERServer|ClientBob)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can add more delimiting keywords in the second (non-capturing) group, seperated by pipes. Keep in mind however that this is quite an "expensive" regex, which could signifcantly impact your search performance. Bot in your case it might be the only way to achive what you need!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 10:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432617#M123616</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-01-31T10:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432618#M123617</link>
      <description>&lt;P&gt;You still need the examples to have the additional characters, the way they would appear IRL, or at least the &lt;CODE&gt;=&lt;/CODE&gt; and &lt;CODE&gt;"&lt;/CODE&gt; characters, because the &lt;CODE&gt;rex&lt;/CODE&gt; I presented above works on this data.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 15:07:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432618#M123617</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2019-01-31T15:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432619#M123618</link>
      <description>&lt;P&gt;No it doesn't. From the example above, let's take this &lt;BR /&gt;
reason="AAABBB";Client="112233",source="aassdd";server="IIHHSS";appName="ooiiuu"&lt;/P&gt;

&lt;P&gt;The text I want to extract is everything between reason= and appName=, which is&lt;BR /&gt;
&lt;STRONG&gt;AAABBB";Client="112233",source="aassdd";server="IIHHSS&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The reason I want all of this together is because&lt;BR /&gt;
1. There are duplicate fields. For example Splunk already has its own field "source" and I don't want to create another&lt;BR /&gt;
2. Yes It's possible to separate everything into different columns so we will have multiples fields like reason, Client, source, server. But as you can see the texts are really dynamic, the column are not always the same. The above examples are only 3 among many other scenarios.  I would need thousands of eval statement to join the fields together which take too much effort.  Those texts are error messages and they are only meaningful when joined together.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 02:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432619#M123618</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-02-01T02:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432620#M123619</link>
      <description>&lt;P&gt;This is exactly something I want, at least logically. However it doesn't work. Splunk only extract all the text between "reason=" and "appName"&lt;BR /&gt;
But it ignores ERServer and ClientBob. Seems the "OR" statement is not recognized properly, is this a bug?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 02:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432620#M123619</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-02-01T02:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432621#M123620</link>
      <description>&lt;P&gt;Thanks for the help mate, but it doesn't work for me. It only extracts single word after "reason="&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 02:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432621#M123620</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-02-01T02:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rex to extract text that ends with either one of multiple words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432622#M123621</link>
      <description>&lt;P&gt;It works perfectly now after changing to this rex below, thanks a lot mate!&lt;/P&gt;

&lt;P&gt;| rex field=_raw "reason=\"(?.*)(appName|ERServer|ClientBob)"&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 03:07:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-to-extract-text-that-ends-with-either-one-of-multiple-words/m-p/432622#M123621</guid>
      <dc:creator>Cbr1sg</dc:creator>
      <dc:date>2019-02-01T03:07:08Z</dc:date>
    </item>
  </channel>
</rss>

