<?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 Feedback on regex on a single string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265589#M79809</link>
    <description>&lt;P&gt;I am trying to regex to get a substring &lt;BR /&gt;
I want substring "addressON" from this string "ThisStreet_addressON_blockb"&lt;/P&gt;

&lt;P&gt;here is my  query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | rex field = streetName "ThisStreet\_(?&amp;lt;thisStreet&amp;gt;)\_blockb$" | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is not working&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:30:03 GMT</pubDate>
    <dc:creator>smhsplunk</dc:creator>
    <dc:date>2020-09-29T11:30:03Z</dc:date>
    <item>
      <title>Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265589#M79809</link>
      <description>&lt;P&gt;I am trying to regex to get a substring &lt;BR /&gt;
I want substring "addressON" from this string "ThisStreet_addressON_blockb"&lt;/P&gt;

&lt;P&gt;here is my  query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | rex field = streetName "ThisStreet\_(?&amp;lt;thisStreet&amp;gt;)\_blockb$" | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is not working&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:30:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265589#M79809</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2020-09-29T11:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265590#M79810</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex (?P&amp;lt;thisStreet&amp;gt;_(\w+)_)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 16:07:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265590#M79810</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-10-19T16:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265591#M79811</link>
      <description>&lt;P&gt;You forgot the format of your regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | rex field = streetName "ThisStreet\_(?&amp;lt;thisStreet&amp;gt;[^ ]*)\_blockb$" | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in this way you take all chars but no spaces between the underscores.&lt;/P&gt;

&lt;P&gt;Eventually try a different one on &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 16:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265591#M79811</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-10-19T16:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265592#M79812</link>
      <description>&lt;P&gt;You're almost there. Your name search is missing the capturing regex. Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | rex field = streetName "ThisStreet_(?&amp;lt;thisStreet&amp;gt;[^_]+)_blockb$" | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternative, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | eval thisStreet=mvindex(split(streetName,"_"),1) | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | eval thisStreet=replace(streetName,"ThisStreet_([^ ]*)_blockb$","\1") | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 16:16:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265592#M79812</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-19T16:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265593#M79813</link>
      <description>&lt;P&gt;For some weird reason only mvindex worked! Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 17:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265593#M79813</guid>
      <dc:creator>smhsplunk</dc:creator>
      <dc:date>2016-10-19T17:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback on regex on a single string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265594#M79814</link>
      <description>&lt;P&gt;The other two methods rely on actual string available before and after the thisStreet that you're trying to extract. The regex in 1st and 3rd option is assuming you have a literal string "ThisStreet_" before and "_blockb" after. If they are not static/literal string, then try like this:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host = "xyz" | search * streetName!="NULL" | table streetName | dedup streetName | rex field = streetName "[^_]+_(?&amp;lt;thisStreet&amp;gt;[^_]+)_.+$" | table thisStreet
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:30:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Feedback-on-regex-on-a-single-string/m-p/265594#M79814</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T11:30:10Z</dc:date>
    </item>
  </channel>
</rss>

