<?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: How to modify my regular expression to extract strings between two pipes? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265728#M79871</link>
    <description>&lt;P&gt;with your update I only had one string which failed and it is because there is no space between the pipe "|" and the letter "i", for instance:&lt;BR /&gt;
AASSDDF DFGJKJ | A&amp;amp;E |FYI will return nothing.&lt;/P&gt;

&lt;P&gt;PS: strings with 2 words between the pipes work just fine!&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 22:43:09 GMT</pubDate>
    <dc:creator>maximusdm</dc:creator>
    <dc:date>2017-01-31T22:43:09Z</dc:date>
    <item>
      <title>How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265722#M79865</link>
      <description>&lt;P&gt;hello, I need to extract the strings between both pipes " | | ", for instance, here are a few sample strings:&lt;BR /&gt;
(sometimes we have a pipe: " I "  and sometimes we have a uppercase letter " i" )&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ASDSAD ASDASD ASDAS | STRING001 | ASDA ASDASD ASDASDADADA
ASDSAD ASDASD ASDAS I STRING002 I ASDA ASDASD ASDASDADADA
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My regular expression works 90% of time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field="Site Section" ".*\|\s*(?&amp;lt;SiteSection&amp;gt;.*)\s*\|"   
| rex field="Site Section" ".*\I\s*(?&amp;lt;SiteSection&amp;gt;.*)\s*\I"  
| rex field="Site Section" ".*\I\s*(?&amp;lt;SiteSection&amp;gt;.*)\s*\|" 
| rex field="Site Section" ".*\|\s*(?&amp;lt;SiteSection&amp;gt;.*)\s*\I" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However it does not work for the strings below:&lt;BR /&gt;
ASDASD ASDASDASDA ADASDADAD I AMC I IFC &amp;lt;=== returns empty&lt;BR /&gt;
 (most likely because of "IFC" string contains a uppercase letter "i")&lt;/P&gt;

&lt;P&gt;ASDASD ASDASDASDA ADASDADAD I DISCO I ADASDA &amp;lt;== returns "ISCO"&lt;BR /&gt;
 (most likely because of "IFC" string contains a uppercase letter "i")&lt;/P&gt;

&lt;P&gt;Any ideas how to modify my regular expression?&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 16:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265722#M79865</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-31T16:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265723#M79866</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field="Site Section" "\s(\||I)\s+(?&amp;lt;SiteSection&amp;gt;.+)\s+(\||I)\s" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 17:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265723#M79866</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-31T17:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265724#M79867</link>
      <description>&lt;P&gt;it is a lot better but still if I have a letter uppercase " i " after the second pipe " | "  then it doesnt work properly. Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 17:44:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265724#M79867</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-31T17:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265725#M79868</link>
      <description>&lt;P&gt;A sample log where it's failing?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 18:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265725#M79868</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-31T18:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265726#M79869</link>
      <description>&lt;P&gt;if you have a string such as: ABCDE I AAA I IFC the results will be "AAA I" and not "AAA" as it should be.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 19:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265726#M79869</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-31T19:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265727#M79870</link>
      <description>&lt;P&gt;The value/string that you want to capture, will it always be a single word or can be multiple words?&lt;BR /&gt;
Try the updated answer as well.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 19:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265727#M79870</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-31T19:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265728#M79871</link>
      <description>&lt;P&gt;with your update I only had one string which failed and it is because there is no space between the pipe "|" and the letter "i", for instance:&lt;BR /&gt;
AASSDDF DFGJKJ | A&amp;amp;E |FYI will return nothing.&lt;/P&gt;

&lt;P&gt;PS: strings with 2 words between the pipes work just fine!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265728#M79871</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-31T22:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265729#M79872</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field="Site Section" "\s(\||I)\s+(?&amp;lt;SiteSection&amp;gt;.+)\s+(\||I\s)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2017 22:47:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265729#M79872</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-31T22:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265730#M79873</link>
      <description>&lt;P&gt;now it fails when there are no spaces between the first pipe LOL&lt;BR /&gt;
for instance:&lt;BR /&gt;
ASDF ASDF| A&amp;amp;E |FYI  or&lt;BR /&gt;
ASDF ASDF |A&amp;amp;E |FYI&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 23:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265730#M79873</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-01-31T23:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265731#M79874</link>
      <description>&lt;P&gt;If still required, can you check this one which shall work in most of the cases:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex field=_raw"\s*(\s*\|\s*(?&amp;lt;captureMe&amp;gt;[^\|]+)\|\s*)"
| table captureMe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/k2M6kH/1"&gt;See extraction here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 23:56:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265731#M79874</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-01-31T23:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify my regular expression to extract strings between two pipes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265732#M79875</link>
      <description>&lt;P&gt;This resolved my problem by replacing the " i " with pipes before the next reg.exp.&lt;/P&gt;

&lt;P&gt;| rex field="Site Section" mode=sed "s,\sI\s, | ,g"&lt;BR /&gt;
| rex field="Site Section" ".&lt;EM&gt;|\s&lt;/EM&gt;(?.&lt;EM&gt;)\s&lt;/EM&gt;|"&lt;/P&gt;

&lt;P&gt;I want to thank you for pointing me to the right direction.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 21:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-my-regular-expression-to-extract-strings-between/m-p/265732#M79875</guid>
      <dc:creator>maximusdm</dc:creator>
      <dc:date>2017-02-02T21:55:25Z</dc:date>
    </item>
  </channel>
</rss>

