<?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: Why does my search return an error &amp;quot;Regex: missing closing parenthesis&amp;quot; when the regular expression is valid? in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302682#M757</link>
    <description>&lt;P&gt;As in for the Computer_Name field? It doesn't even &lt;EM&gt;attempt&lt;/EM&gt; to run the regex, it just dies on compiling the regex. The problem isn't that it's not &lt;EM&gt;matching&lt;/EM&gt; the Regex, it's that it dies before it even &lt;EM&gt;attempts&lt;/EM&gt; to match the Regex.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 23:19:07 GMT</pubDate>
    <dc:creator>CaninChristellC</dc:creator>
    <dc:date>2017-02-16T23:19:07Z</dc:date>
    <item>
      <title>Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302679#M754</link>
      <description>&lt;P&gt;With the following search:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index=digitalguardian | transaction Computer_Name | rex  (?&amp;lt;=\\)(?&amp;lt;SiteCode&amp;gt;.{3})(?=-)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get the following error:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '(?&amp;lt;=)(?.{3})(?=-)': Regex: missing closing parenthesis&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Testing the regex in a Regex tester (specifically regex101.com) the regex tests as valid, and properly matches the intended characters. Further, examining the expression there seems to be a proper number of parenthesis (opening and closing) both in the expression and error message.&lt;/P&gt;
&lt;P&gt;Why is Splunk handling this regular expression in this manner?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 16:56:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302679#M754</guid>
      <dc:creator>CaninChristellC</dc:creator>
      <dc:date>2020-06-10T16:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302680#M755</link>
      <description>&lt;P&gt;Upon further review, it appears that Splunk is choking on the escaped backslash, and interpreting it as escaping the parenthesis mark. As one might expect, removing the first backslash to not escape the backslash also produces the same error.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 23:07:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302680#M755</guid>
      <dc:creator>CaninChristellC</dc:creator>
      <dc:date>2017-02-16T23:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302681#M756</link>
      <description>&lt;P&gt;some sample data would help ful?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 23:12:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302681#M756</guid>
      <dc:creator>vasanthmss</dc:creator>
      <dc:date>2017-02-16T23:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302682#M757</link>
      <description>&lt;P&gt;As in for the Computer_Name field? It doesn't even &lt;EM&gt;attempt&lt;/EM&gt; to run the regex, it just dies on compiling the regex. The problem isn't that it's not &lt;EM&gt;matching&lt;/EM&gt; the Regex, it's that it dies before it even &lt;EM&gt;attempts&lt;/EM&gt; to match the Regex.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 23:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302682#M757</guid>
      <dc:creator>CaninChristellC</dc:creator>
      <dc:date>2017-02-16T23:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302683#M758</link>
      <description>&lt;P&gt;I am admittedly curious about the use of positive lookahead and behind, as opposed to just matching the slash and dash characters outright as it seems like this would add steps to your regex matching, but in any case.... &lt;/P&gt;

&lt;P&gt;This might be worth a filing a bug on your support contract, as it does seem fairly odd (I tried things out on both Splunk 6.3.8 and 6.5.2)&lt;/P&gt;

&lt;P&gt;I think you want &lt;CODE&gt;| rex  "\\\(?&amp;lt;SiteCode&amp;gt;.{3})-"&lt;/CODE&gt; No it doesn't pass regex101's checker, but I think Splunk may be reading the argument to rex as a string, so backslash escaping is happening with the simple reading of the string so then too few slashes are present when it then goes to parse the regex. It seems to work fine with 3 or 4 backslashes... Try these run anywhere queries: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="FOO BAR\BIG-banananananana" | rex  (?&amp;lt;=\\\)(?&amp;lt;SiteCode&amp;gt;.{3})(?=-)

| makeresults | eval _raw="FOO BAR\BIG-banananananana" | rex  \\\(?&amp;lt;SiteCode&amp;gt;.{3})-

| makeresults | eval _raw="FOO BAR\BIG-banananananana" | rex  "\\\(?&amp;lt;SiteCode&amp;gt;.{3})-"

| makeresults | eval _raw="FOO BAR\BIG-banananananana" | rex  "\\\\(?&amp;lt;SiteCode&amp;gt;.{3})-"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Offtopic... regarding your search, I think &lt;CODE&gt;transaction&lt;/CODE&gt; should preserve values from extracted fields, so you should be able to invert your rex and transaction command, which if you're in a distributed environment would mean your rex would be distributed to your indexers instead of having to run on your search head after the transaction command occurs.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 23:59:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302683#M758</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2017-02-16T23:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302684#M759</link>
      <description>&lt;P&gt;@CaninChristellCOP - Did the answer provided by acharlieh help provide a working solution to your question? If yes, please don't forget to resolve this post by clicking "Accept". If no, please leave a comment with more feedback. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 02:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302684#M759</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-03-20T02:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302685#M760</link>
      <description>&lt;P&gt;I have similar error. My following search in splunkUI works fine&lt;/P&gt;

&lt;P&gt;index="appIndex*" host="somehost" | fields TransUID | rex field=_raw "^[^[\n]*[(?P[^]]+)"| transaction TransUID &lt;/P&gt;

&lt;P&gt;But when I use the same query in javascript (SplunkJS) in my webapp I get following error.&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '^[^[ ]*[(?P[^]]+)': Regex: unmatched closing parenthesis &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:16:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302685#M760</guid>
      <dc:creator>AshChakor</dc:creator>
      <dc:date>2020-09-30T00:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why does my search return an error "Regex: missing closing parenthesis" when the regular expression is valid?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302686#M761</link>
      <description>&lt;P&gt;Thanks acharlieh.&lt;BR /&gt;
It's working after I changed it to *\[(?P[^]]+)".&lt;/P&gt;

&lt;P&gt;index="appIndex*" host="somehost" | rex field=_raw "^[^[\n]*\[(?P[^]]+)" | transaction TransUID&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:16:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Why-does-my-search-return-an-error-quot-Regex-missing-closing/m-p/302686#M761</guid>
      <dc:creator>AshChakor</dc:creator>
      <dc:date>2020-09-30T00:16:42Z</dc:date>
    </item>
  </channel>
</rss>

