<?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: Going crazy with simple Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470616#M132386</link>
    <description>&lt;P&gt;Hi Zakary_n,&lt;BR /&gt;
probably the problem is "=" that's a special char and must be escaped.&lt;BR /&gt;
Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "Instrument\=\\\"(?&amp;lt;Instrument&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/LBvB3S/1"&gt;https://regex101.com/r/LBvB3S/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 28 Oct 2019 10:58:23 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-10-28T10:58:23Z</dc:date>
    <item>
      <title>Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470615#M132385</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I wasted way too much time on my not working regex : &lt;/P&gt;

&lt;P&gt;Here's what my _raw data looks like : &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt; Instrument=\"Guitar\" Price=\"500\" &amp;gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I would like to add an "instrument" field on my events but my regex wont work in Splunk (And it's working in other environments!).&lt;/P&gt;

&lt;P&gt;My regex so far : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mySearch
| rex field=_raw  "Instrument=\"(?&amp;lt;instrument&amp;gt;.*)\""
| fields instrument
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know, I've tried escaping the backquotes like this : &lt;CODE&gt;"Instrument=\\"(?&amp;lt;instrument&amp;gt;.*)\\""&lt;/CODE&gt; but this way I get a closing parenthesis error.&lt;/P&gt;

&lt;P&gt;I've also tried : &lt;CODE&gt;"Instrument=\\\"(?&amp;lt;instrument&amp;gt;.*)\\\""&lt;/CODE&gt;, but same, this will only return my raw events.&lt;/P&gt;

&lt;P&gt;Do you guys have an idea how to achieve this and create the field "instrument=Guitar" on my events ?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 10:07:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470615#M132385</guid>
      <dc:creator>Zakary_n</dc:creator>
      <dc:date>2019-10-28T10:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470616#M132386</link>
      <description>&lt;P&gt;Hi Zakary_n,&lt;BR /&gt;
probably the problem is "=" that's a special char and must be escaped.&lt;BR /&gt;
Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "Instrument\=\\\"(?&amp;lt;Instrument&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/LBvB3S/1"&gt;https://regex101.com/r/LBvB3S/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 10:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470616#M132386</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-10-28T10:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470617#M132387</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;The actual problem was with capture group ".&lt;EM&gt;", it is called greedy regex.&lt;BR /&gt;
It may be capturing the value &lt;CODE&gt;Guitar" Price="500&lt;/CODE&gt;,as you are using ".&lt;/EM&gt;"&lt;BR /&gt;
The following regex will work,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval test="&amp;lt; Instrument=\"Guitar\" Price=\"500\" &amp;gt;" | rex field=test "Instrument=\"(?&amp;lt;instrument&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Accept &amp;amp; up-vote the answer if it helps.&lt;BR /&gt;
happy splunking....!!!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 11:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470617#M132387</guid>
      <dc:creator>gaurav_maniar</dc:creator>
      <dc:date>2019-10-28T11:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470618#M132388</link>
      <description>&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "Instrument=\"(?&amp;lt;instrument&amp;gt;[^\"]+)\""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 11:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470618#M132388</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-10-28T11:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470619#M132389</link>
      <description>&lt;P&gt;This helped a lot. Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 12:11:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470619#M132389</guid>
      <dc:creator>Zakary_n</dc:creator>
      <dc:date>2019-10-28T12:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470620#M132390</link>
      <description>&lt;P&gt;This was helpful in finding the answer as well. Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 12:15:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470620#M132390</guid>
      <dc:creator>Zakary_n</dc:creator>
      <dc:date>2019-10-28T12:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470621#M132391</link>
      <description>&lt;P&gt;This is a solid tactic: the not-match. I find this works well when you know what character does NOT belong (in this case, the double quote) and the parser will will match up to that. Simple, clean, easy to understand.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 12:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470621#M132391</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-10-28T12:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470622#M132392</link>
      <description>&lt;P&gt;Try this :&lt;/P&gt;

&lt;P&gt;|rex "Instrument=\"(?[^\"]+)\""&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 13:43:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470622#M132392</guid>
      <dc:creator>tmuthuk</dc:creator>
      <dc:date>2019-10-28T13:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Going crazy with simple Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470623#M132393</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You Can also try this simple one. It will also work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex "(?&amp;lt;Instrument_Name&amp;gt;[\w]+)\\\"\s\w"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test your rex : &lt;CODE&gt;&lt;A href="https://regex101.com/r/WNni5C/4" target="test_blank"&gt;https://regex101.com/r/WNni5C/4&lt;/A&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 10:35:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Going-crazy-with-simple-Regex/m-p/470623#M132393</guid>
      <dc:creator>vikcee</dc:creator>
      <dc:date>2019-10-29T10:35:24Z</dc:date>
    </item>
  </channel>
</rss>

