<?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 Extract String That is Between 2 Fixed Words in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137923#M37842</link>
    <description>&lt;P&gt;I have not been able to produce a single regex string that will match all four of those strings.  Perhaps you can use sed to replace numbers with another character.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;Phrase&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;" | rex field=Phrase mode=sed "s/\d/x/g" | stats count by Phrase
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Apr 2015 20:28:54 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2015-04-08T20:28:54Z</dc:date>
    <item>
      <title>Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137908#M37827</link>
      <description>&lt;P&gt;I have 61 events which have a string between ''and ''&lt;/P&gt;

&lt;P&gt;There's 3-4 different phrases that go between those 2 fixed strings. So I need a regular expression which can pick up whatever phrase is between ''and ''. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;a:OrderMessage&amp;gt;Missed Delivery cut-off, Redated&amp;lt;/a:OrderMessage&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Phrase = "Missed Delivery cut-off, Redated"&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 01:41:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137908#M37827</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T01:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137909#M37828</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;Phrase&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 01:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137909#M37828</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-08T01:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137910#M37829</link>
      <description>&lt;P&gt;You can also test this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ...|rex "(?i):OrderMessage&amp;gt;(?P&amp;lt;phrase&amp;gt;[^&amp;lt;]+)"|table phrase
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 02:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137910#M37829</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-08T02:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137911#M37830</link>
      <description>&lt;P&gt;Thanks for the help. I put in your query and getting an 'Error in rex command'&lt;/P&gt;

&lt;P&gt;Here's my search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;*&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I put a '*' where you had 'phrase'. I have 4-5 phrases/strings that will show up so I can't hardcode the phrase/string in the regex. Any other ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:53:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137911#M37830</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T12:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137912#M37831</link>
      <description>&lt;P&gt;Thanks for the help. I put in your query and getting an 'Error in rex command'&lt;/P&gt;

&lt;P&gt;Here's my search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;*&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I put a '*' where you had 'phrase'. I have 4-5 phrases/strings that will show up so I can't hardcode the phrase/string in the regex. Any other ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137912#M37831</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T12:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137913#M37832</link>
      <description>&lt;P&gt;Asterisks are not valid there.  The word 'phrase' is a field declaration, not a hardcoding.  When the rex command executes, it will store the string it finds between the two fixed strings in the field called 'phrase' which you then can use in other SPL commands.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 13:00:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137913#M37832</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-08T13:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137914#M37833</link>
      <description>&lt;P&gt;So I need to create a field called 'phrase'? &lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 13:10:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137914#M37833</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T13:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137915#M37834</link>
      <description>&lt;P&gt;The rex command will create the field.  Please try the regex string I gave you.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 13:38:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137915#M37834</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-08T13:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137916#M37835</link>
      <description>&lt;P&gt;Why? you don't have to change anything in the search query, instead add your basic search to replace the &lt;STRONG&gt;...&lt;/STRONG&gt; before the &lt;STRONG&gt;|rex&lt;/STRONG&gt; . The regex will extract all the values you need, create a field named &lt;STRONG&gt;phrase&lt;/STRONG&gt; and put all that values inside.Test it and let me know if you still have issues&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 14:11:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137916#M37835</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-08T14:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137917#M37836</link>
      <description>&lt;P&gt;This worked almost perfectly. The only issue now is &lt;/P&gt;

&lt;P&gt;One of the Phrases is &lt;CODE&gt;"Missed Delivery cut-off, Redated to (01/15/15)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;There will be different dates after the 'Missed Delivery cut-off, Redated' and the regex you gave me sorts the phrases with a different date as an independent event. &lt;/P&gt;

&lt;P&gt;So I would like to count 'Missed Delivery cut-off, Redated to' as one regardless of what the date is.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 14:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137917#M37836</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T14:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137918#M37837</link>
      <description>&lt;P&gt;Yes exactly what I was looking for. The only issue now is that the date after "Missed Delivery cut-off, Redated to" can change and I only want to grab that phrase once and have it count each instance, regardless of what the date is.&lt;/P&gt;

&lt;P&gt;Can you help with new regex which could only count the different phrases and ignore the dates? &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Here is what I'm seeing&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Missed Delivery cut-off, Redated to (01/15/15)"
"Missed Delivery cut-off, Redated to (01/19/15)"
"Missed Delivery cut-off, Redated to (01/25/15)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I want it to only capture the this string and have it count the occurrences &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "Missed Delivery cut-off, Redated to" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 14:48:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137918#M37837</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137919#M37838</link>
      <description>&lt;P&gt;I basically want to ignore numbers and only identify letters &lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 16:14:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137919#M37838</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T16:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137920#M37839</link>
      <description>&lt;P&gt;Ok here you go &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|rex "(?i):OrderMessage&amp;gt;(?P&amp;lt;phrase&amp;gt;[^(&amp;lt;]+)"|table phrase
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For the count you can use &lt;STRONG&gt;stats&lt;/STRONG&gt; command instead of table, depending of what you want&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 17:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137920#M37839</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-08T17:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137921#M37840</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;Phrase&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;" | rex field=Phrase "(?P&amp;lt;truncatedPhrase&amp;gt;[^\d\(]+)[\d\(]" | stats count by truncatedPhrase
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 19:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137921#M37840</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-08T19:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137922#M37841</link>
      <description>&lt;P&gt;This is very very close to what I need. It successfully counts the number of instances and ignores all the numbers. &lt;/P&gt;

&lt;P&gt;Only 2 issues now, &lt;/P&gt;

&lt;P&gt;1) I have 4 different phrases/strings and your search is only counting 3 of them (missing the 4th one.. FRD).&lt;/P&gt;

&lt;P&gt;2) One of the phrases is &lt;CODE&gt;"Pulled ship date  of 04/17/15 on Express because Customer Master flagged as HLD."&lt;/CODE&gt; and it's currently showing up as "Pulled ship date of".. I need it to show "Flagged as HLD"&lt;/P&gt;

&lt;P&gt;Here are the 4 phrases/strings &lt;/P&gt;

&lt;P&gt;1) Existing account, Changed phone from 1111111111 to 2222222222&lt;BR /&gt;
2) Missed Delivery cut-off, Redated to 04/18/2015&lt;BR /&gt;
3) Pulled ship date  of 04/17/15 on Express because Customer Master flagged as HLD.&lt;BR /&gt;
4) Pulled ship date  of 04/17/15 on Express because Customer Master flagged as FRD.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 19:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137922#M37841</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2015-04-08T19:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137923#M37842</link>
      <description>&lt;P&gt;I have not been able to produce a single regex string that will match all four of those strings.  Perhaps you can use sed to replace numbers with another character.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\&amp;lt;a:OrderMessage\&amp;gt;(?P&amp;lt;Phrase&amp;gt;.*?)\&amp;lt;\/a:OrderMessage\&amp;gt;" | rex field=Phrase mode=sed "s/\d/x/g" | stats count by Phrase
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 20:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137923#M37842</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-04-08T20:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137924#M37843</link>
      <description>&lt;P&gt;What about extracting fields from the following single-event XML ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;CONTROL&amp;gt; 
&amp;lt;VLN_ID&amp;gt;1001&amp;lt;/VLN_ID&amp;gt;
&amp;lt;VLN_NAME&amp;gt;vulnerability name 001&amp;lt;/VLN_NAME&amp;gt;
&amp;lt;VLN_SEVERITY&amp;gt;2&amp;lt;/VLN_SEVERITY&amp;gt;
&amp;lt;VLN_CATEGORY&amp;gt;Audit&amp;lt;/VLN_CATEGORY&amp;gt; 
&amp;lt;VLN_SCAN_CODE&amp;gt;0&amp;lt;/VLN_SCAN_CODE&amp;gt;
&amp;lt;VLN_SCAN_MESSAGE&amp;gt;successfully completed&amp;lt;/VLN_SCAN_MESSAGE&amp;gt;
&amp;lt;VLN_CTRL_FIND&amp;gt;0&amp;lt;/VLN_CTRL_FIND&amp;gt;
&amp;lt;VLN_CTRL_SUMMARY&amp;gt;ALDO1, ALTIN1&amp;lt;/VLN_CTRL_SUMMARY&amp;gt;
&amp;lt;VLN_CTRL_OUTPUT&amp;gt;xxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxxxxxxxx&amp;lt;/VLN_CTRL_OUTPUT&amp;gt;
&amp;lt;/CONTROL&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;without REX or SPATH, how can one get the field just between two unique strings (XLM field tags) ?&lt;/P&gt;

&lt;P&gt;regards&lt;BR /&gt;
Altin&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 12:44:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137924#M37843</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2017-04-11T12:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to Extract String That is Between 2 Fixed Words</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137925#M37844</link>
      <description>&lt;P&gt;You're adding to an old discussion that has an accepted answer.  It's unlikely your question will be seen.  Please post a new question.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 13:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-Extract-String-That-is-Between-2-Fixed-Words/m-p/137925#M37844</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-04-11T13:36:08Z</dc:date>
    </item>
  </channel>
</rss>

