<?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 Positive lookahead in rex to extract ABC, BCD, &amp;amp; CDE from ABCDE in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525313#M148224</link>
    <description>&lt;P&gt;Hi, folks.&lt;BR /&gt;&lt;BR /&gt;I am stumped on this matter. My goal is extracting ABC, BCE, &amp;amp; CDE from ABCDE into a multivalue field.&lt;/P&gt;&lt;P&gt;So far, I have played around with regex101.com and got these 2 regex:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;(?&amp;lt;field_1&amp;gt;(?=(\w{3})))&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;(?&amp;lt;field_2&amp;gt;(?&amp;lt;=(\w{3})))&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Both seem to work on regex101.com&lt;/P&gt;&lt;P&gt;But the thing is, I always get empty results in Splunk. I was using this command&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| makeresults | eval sample="ABCDE" | rex field=sample max_match=0 "(?&amp;lt;field_1&amp;gt;(?=(\w{3})))"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I understand that I was using positive lookahead and positive lookbehind. I opt to use one of them, since I'm not aware of how many characters the original field would have. So, either lookahead or lookbehind seems to be the appropriate method to do.&lt;/P&gt;&lt;P&gt;Are these two methods available in Splunk? Or am I doing this in a wrong way?&lt;/P&gt;&lt;P&gt;Please advise.&lt;BR /&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 11:11:18 GMT</pubDate>
    <dc:creator>Amusthofa</dc:creator>
    <dc:date>2020-10-19T11:11:18Z</dc:date>
    <item>
      <title>Positive lookahead in rex to extract ABC, BCD, &amp; CDE from ABCDE</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525313#M148224</link>
      <description>&lt;P&gt;Hi, folks.&lt;BR /&gt;&lt;BR /&gt;I am stumped on this matter. My goal is extracting ABC, BCE, &amp;amp; CDE from ABCDE into a multivalue field.&lt;/P&gt;&lt;P&gt;So far, I have played around with regex101.com and got these 2 regex:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;(?&amp;lt;field_1&amp;gt;(?=(\w{3})))&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;(?&amp;lt;field_2&amp;gt;(?&amp;lt;=(\w{3})))&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Both seem to work on regex101.com&lt;/P&gt;&lt;P&gt;But the thing is, I always get empty results in Splunk. I was using this command&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| makeresults | eval sample="ABCDE" | rex field=sample max_match=0 "(?&amp;lt;field_1&amp;gt;(?=(\w{3})))"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I understand that I was using positive lookahead and positive lookbehind. I opt to use one of them, since I'm not aware of how many characters the original field would have. So, either lookahead or lookbehind seems to be the appropriate method to do.&lt;/P&gt;&lt;P&gt;Are these two methods available in Splunk? Or am I doing this in a wrong way?&lt;/P&gt;&lt;P&gt;Please advise.&lt;BR /&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 11:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525313#M148224</guid>
      <dc:creator>Amusthofa</dc:creator>
      <dc:date>2020-10-19T11:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Positive lookahead in rex to extract ABC, BCD, &amp; CDE from ABCDE</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525340#M148231</link>
      <description>&lt;P&gt;seems positive lookahead and look behind is not working in Splunk regex.&lt;/P&gt;&lt;P&gt;(?=(?&amp;lt;field_1&amp;gt;\w{3}))&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 12:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525340#M148231</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-10-19T12:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Positive lookahead in rex to extract ABC, BCD, &amp; CDE from ABCDE</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525341#M148232</link>
      <description>&lt;P&gt;Hi, thanks for responding.&lt;/P&gt;&lt;P&gt;I have been trying that too, but all I get is only ABC.&lt;/P&gt;&lt;P&gt;If I use it like this:&lt;BR /&gt;| makeresults&lt;BR /&gt;| eval sample="ABCDE"&lt;BR /&gt;| rex fields=sample max_match=3 "&lt;SPAN&gt;(?=(?&amp;lt;field_1&amp;gt;\w{3})) "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Then all I got were:&lt;BR /&gt;ABC&lt;BR /&gt;ABC&lt;BR /&gt;ABC&lt;/P&gt;&lt;P&gt;I'm not really sure about the logic though.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 12:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/525341#M148232</guid>
      <dc:creator>Amusthofa</dc:creator>
      <dc:date>2020-10-19T12:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Positive lookahead in rex to extract ABC, BCD, &amp; CDE from ABCDE</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/527468#M148896</link>
      <description>&lt;P&gt;Hi, folks.&lt;BR /&gt;&lt;BR /&gt;I've been tinkering around these 2 weeks and finally found a solution. Sort of. This is basically a haphazard workaround.&lt;/P&gt;&lt;P&gt;The first thing I did was trying make it more readable. Instead of &lt;STRONG&gt;ABCDE&lt;/STRONG&gt;, I used &lt;STRONG&gt;A B C D E&lt;/STRONG&gt;. Basically putting a delimiter between characters. Thus, my regex also changed into something like this &lt;STRONG&gt;(?=(?&amp;lt;field1&amp;gt;\w\s\w\s\w))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;That regex didn't work, unfortunately.&lt;/P&gt;&lt;P&gt;Then I wonder if the regex actually need something to anchor on. So, I manipulated my original text again by adding a space before &lt;STRONG&gt;A&lt;/STRONG&gt;. My regex became like this &lt;STRONG&gt;\s(?=(?&amp;lt;field1&amp;gt;\w\s\w\s\w))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I got my intended results, but I still wonder why Splunk's regex engine behaves like that.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:&amp;nbsp;&lt;/STRONG&gt;I had to use&amp;nbsp;&lt;STRONG&gt;\w\s\w\s\w&lt;/STRONG&gt; since&amp;nbsp;&lt;STRONG&gt;.....&amp;nbsp;&lt;/STRONG&gt;or&amp;nbsp;&lt;STRONG&gt;.{5}&amp;nbsp;&lt;/STRONG&gt;didn't work when I tried them.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE2&lt;/STRONG&gt;: The delimiter between characters and the "anchor" before the first character must be EXACTLY THE SAME.&lt;/P&gt;&lt;P&gt;Full SPL:&lt;/P&gt;&lt;LI-SPOILER&gt;| makeresults&lt;BR /&gt;| eval text="ABCDEFG"&lt;BR /&gt;| rex field=text mode=sed "s/(\w)/\1 /g"&lt;BR /&gt;| eval text=" "+text&lt;BR /&gt;| rex field=text max_match=0 "\s(?=(?&amp;lt;field1&amp;gt;\w\s\w\s\w))"&amp;nbsp;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;Screenshot attached&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 06:25:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Positive-lookahead-in-rex-to-extract-ABC-BCD-amp-CDE-from-ABCDE/m-p/527468#M148896</guid>
      <dc:creator>Amusthofa</dc:creator>
      <dc:date>2020-11-02T06:25:25Z</dc:date>
    </item>
  </channel>
</rss>

