<?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 is correct but splunk throws error in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447326#M126816</link>
    <description>&lt;P&gt;my guess is reason of failure is due to you not escaping double quotes &lt;CODE&gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Try something like..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=* sourcetype="*" source="example.log" "msg=Patch for deviceId*" | rex "code\\\"\:\\\"(?&amp;lt;codes&amp;gt;.{20})" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2019 20:51:42 GMT</pubDate>
    <dc:creator>koshyk</dc:creator>
    <dc:date>2019-08-14T20:51:42Z</dc:date>
    <item>
      <title>Regex is correct but splunk throws error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447325#M126815</link>
      <description>&lt;P&gt;For the following log, I would like to filter by a string. I would have to extract the string using regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;traceId=xyz msg=Patch for deviceId with body {"parameters":[{"value":"{\"code\":\"ABC_DEF_SEND_MACBOOKS\",\"commands\.....}
traceId=xyz msg=Patch for deviceId with body {"parameters":[{"value":"{\"code\":\"ABC_DEF_OPEN_MACBOOKS\",\"commands\.....}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Splunk query is as follows.&lt;BR /&gt;
&lt;CODE&gt;host=* sourcetype="*" source="example.log" "msg=Patch for deviceId*" | rex "code\\"\:\\"(?&amp;lt;codes&amp;gt;.{20})" | where codes=ABC_DEF_SEND_MACBOOKS&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;But splunk throws the below error related to regex&lt;BR /&gt;
&lt;CODE&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'code\\:\(?&amp;lt;codes&amp;gt;.{20})': Regex: unmatched closing parenthesis&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;When I checked the regex in regex101.com, the output for &lt;CODE&gt;codes&lt;/CODE&gt; is as expected. &lt;BR /&gt;
What is wrong with the parenthesis in this case?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 20:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447325#M126815</guid>
      <dc:creator>amunag439</dc:creator>
      <dc:date>2019-08-14T20:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex is correct but splunk throws error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447326#M126816</link>
      <description>&lt;P&gt;my guess is reason of failure is due to you not escaping double quotes &lt;CODE&gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Try something like..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=* sourcetype="*" source="example.log" "msg=Patch for deviceId*" | rex "code\\\"\:\\\"(?&amp;lt;codes&amp;gt;.{20})" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 20:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447326#M126816</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2019-08-14T20:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex is correct but splunk throws error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447327#M126817</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    host=* sourcetype="*" source="example.log" "msg=Patch for deviceId*" |  rex field=_raw "code\\\+\":+\\\+\"(?&amp;lt;codes&amp;gt;.*?)\\\+" | where codes="ABC_DEF_SEND_MACBOOKS"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in your where condition you also need to have your string within quotes like above&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 06:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-is-correct-but-splunk-throws-error/m-p/447327#M126817</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-15T06:49:25Z</dc:date>
    </item>
  </channel>
</rss>

