<?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 in query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307692#M92290</link>
    <description>&lt;P&gt;Hi jacqu3sy,&lt;BR /&gt;
try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "\#(?&amp;lt;my_field&amp;gt;[^\#]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Sun, 15 Oct 2017 08:04:27 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-10-15T08:04:27Z</dc:date>
    <item>
      <title>Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307688#M92286</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can anyone help with a regex to extract into a new field anything contained within raw data after a #?&lt;/P&gt;

&lt;P&gt;For example, the following data from twitter;&lt;/P&gt;

&lt;H1&gt;opIcarus #opBlackOctober #opSacred #opMASSHACK ENGAGED &lt;A href="https://t.co/JiWVA4kOXr"&gt;https://t.co/JiWVA4kOXr&lt;/A&gt;&lt;/H1&gt;

&lt;P&gt;I'd like a way to extract and list all the content after each hash.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2017 15:38:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307688#M92286</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-10-14T15:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307689#M92287</link>
      <description>&lt;P&gt;Hi jacqu3sy,&lt;BR /&gt;
try this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\#(?&amp;lt;my_field&amp;gt;[^\#]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can test it at &lt;A href="https://regex101.com/r/Sk52x3/1"&gt;https://regex101.com/r/Sk52x3/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2017 15:51:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307689#M92287</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-14T15:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307690#M92288</link>
      <description>&lt;P&gt;Not quite. It pulls out the first #hashtag within the _raw field, but ignores the others. So in the example above, it would extract #opBlackOctober, but ignore the others.&lt;/P&gt;

&lt;P&gt;Is there a way of extracting all? Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2017 17:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307690#M92288</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-10-14T17:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307691#M92289</link>
      <description>&lt;P&gt;I think this should do what you're looking for:&lt;BR /&gt;
&lt;CODE&gt;rex max_match=0 field=_raw \#(?&amp;lt;extracted_field&amp;gt;[^\# ]*)&lt;/CODE&gt;&lt;BR /&gt;
The keys here are the &lt;CODE&gt;max_match&lt;/CODE&gt; argument, which tells  &lt;CODE&gt;rex&lt;/CODE&gt; to not stop at the first match, and also a slight modification to the regex that @cusello suggested (by adding a space to the ignored characters). Without that modification, I believe you will get erroneous matches.&lt;/P&gt;

&lt;P&gt;Note that the  &lt;CODE&gt;max_match&lt;/CODE&gt; argument defaults to the value of 1. Setting it to 0 makes it unlimited, but you could set it to some other specific value if you only wanted to match a certain number of instances. Here is some info in the docs:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Rex"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/Rex&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2017 23:43:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307691#M92289</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2017-10-14T23:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307692#M92290</link>
      <description>&lt;P&gt;Hi jacqu3sy,&lt;BR /&gt;
try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 "\#(?&amp;lt;my_field&amp;gt;[^\#]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2017 08:04:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307692#M92290</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-10-15T08:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex in query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307693#M92291</link>
      <description>&lt;P&gt;Perfect - thank you for the detailed response. It's much appreciated.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2017 09:46:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-in-query/m-p/307693#M92291</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2017-10-15T09:46:59Z</dc:date>
    </item>
  </channel>
</rss>

