<?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 Help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298242#M89941</link>
    <description>&lt;P&gt;Don't replace &lt;CODE&gt;.*&lt;/CODE&gt; with &lt;CODE&gt;?&amp;lt;fieldName&amp;gt;&lt;/CODE&gt;.  You add &lt;CODE&gt;?&amp;lt;fieldName&amp;gt;&lt;/CODE&gt; after your &lt;CODE&gt;(&lt;/CODE&gt;, like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"errorCode\":(?&amp;lt;errorCode&amp;gt;.*?)},
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Full rex (alteration to exclude double quotes from the extracted value):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;.*?)\"},"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Probably better version, which specifies that errorCode can't contain &lt;CODE&gt;"&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;[^\"]+)\"},"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Jan 2018 23:31:53 GMT</pubDate>
    <dc:creator>micahkemp</dc:creator>
    <dc:date>2018-01-08T23:31:53Z</dc:date>
    <item>
      <title>Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298241#M89940</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Struggling yet again with another regex. The sample string looks like the following:&lt;/P&gt;

&lt;P&gt;.........,"errorCode":"500113"}, .......&lt;/P&gt;

&lt;P&gt;As part of a whole JSON response.&lt;/P&gt;

&lt;P&gt;If I take that JSON and put it into regex101, I can use the following rex to correctly capture the code&lt;/P&gt;

&lt;P&gt;"errorCode\":(.*?)},&lt;/P&gt;

&lt;P&gt;However, I'm not sure how to turn that into a rex command to parse out the field. If I simply replace the .* with ?&amp;lt;&amp;gt;  with a field name inside the brackets it errors out, and in fact I can't ever get it to not throw an error.&lt;/P&gt;

&lt;P&gt;How do I turn an accurate regular expression(at least from my testing using online regular expression tools) into a rex command to capture a field in Splunk?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 23:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298241#M89940</guid>
      <dc:creator>brajaram</dc:creator>
      <dc:date>2018-01-08T23:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298242#M89941</link>
      <description>&lt;P&gt;Don't replace &lt;CODE&gt;.*&lt;/CODE&gt; with &lt;CODE&gt;?&amp;lt;fieldName&amp;gt;&lt;/CODE&gt;.  You add &lt;CODE&gt;?&amp;lt;fieldName&amp;gt;&lt;/CODE&gt; after your &lt;CODE&gt;(&lt;/CODE&gt;, like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"errorCode\":(?&amp;lt;errorCode&amp;gt;.*?)},
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Full rex (alteration to exclude double quotes from the extracted value):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;.*?)\"},"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Probably better version, which specifies that errorCode can't contain &lt;CODE&gt;"&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\"errorCode\":\"(?&amp;lt;errorCode&amp;gt;[^\"]+)\"},"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jan 2018 23:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298242#M89941</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-08T23:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298243#M89942</link>
      <description>&lt;P&gt;Ahh, thanks for the explanation! Works perfectly. Appreciate the help!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 23:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298243#M89942</guid>
      <dc:creator>brajaram</dc:creator>
      <dc:date>2018-01-08T23:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298244#M89943</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;The feeling you have when you are too late to a regex question :S&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 12:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/298244#M89943</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-01-09T12:15:23Z</dc:date>
    </item>
  </channel>
</rss>

