<?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: how to identify malformed regex ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553783#M157233</link>
    <description>&lt;P&gt;Thanks Venkatasri for you answer.&lt;/P&gt;&lt;P&gt;I simply have a lookup which contains list of patterns some are malformed and some are good, the idea is to process then using regex and identify if some of then are malformed or not.&lt;/P&gt;&lt;P&gt;In Order to check from the _internal I need to first run it&lt;/P&gt;&lt;P&gt;Like - regex "My Pattern"&amp;nbsp; and then i can see there is an error.&lt;/P&gt;&lt;P&gt;But in my case I have a lookup which contains around 300 pattern or so and I need to check if any of those are malformed or not ?I am not sure how to run 300 pattern present in some lookup in one go?&lt;/P&gt;&lt;P&gt;Again, thanks for your response and let me know if you have any queries around my question.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jun 2021 06:26:11 GMT</pubDate>
    <dc:creator>tarunmalhotra79</dc:creator>
    <dc:date>2021-06-01T06:26:11Z</dc:date>
    <item>
      <title>how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553700#M157214</link>
      <description>&lt;P&gt;Dear Splunker,&lt;/P&gt;&lt;P&gt;I have a lookup, which contains all the regex patterns. I would like to identify which of them are malformed.&lt;/P&gt;&lt;P&gt;When i say malformed, I simply mean missing parenthesis or may be some mismatch in basic regular expressions.&lt;/P&gt;&lt;P&gt;For ex- ((hostA.*,hostB.*) // This will be malformed as its missing last parenthesis.&lt;/P&gt;&lt;P&gt;If i run this command in splunk&amp;nbsp;&lt;/P&gt;&lt;P&gt;| regex "((hostA.*,hostB.*)"&lt;/P&gt;&lt;P&gt;It will give me the error , missing parenthesis and will immediately stop the execution , I am trying to find such kind of error proactively and correct them.&lt;/P&gt;&lt;P&gt;Any help would be really appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2021 09:32:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553700#M157214</guid>
      <dc:creator>tarunmalhotra79</dc:creator>
      <dc:date>2021-05-31T09:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553731#M157219</link>
      <description>&lt;P&gt;Splunk doesn't have a command to preprocess regular expressions.&amp;nbsp; Consider writing an external command that does so.&amp;nbsp; Or just upload your lookup to an on-line regex checker.&amp;nbsp; Or write a Python script to check the regexes.&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2021 15:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553731#M157219</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-05-31T15:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553746#M157226</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/207965"&gt;@tarunmalhotra79&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Found some log events related to rex, you can give a try if it helps.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal sourcetype=splunkd rex* OR regex* (ERROR OR WARN)&lt;/LI-CODE&gt;&lt;P&gt;-----------------------------------------------------&lt;/P&gt;&lt;P&gt;An upvote would be appreciated if it helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 00:34:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553746#M157226</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-01T00:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553783#M157233</link>
      <description>&lt;P&gt;Thanks Venkatasri for you answer.&lt;/P&gt;&lt;P&gt;I simply have a lookup which contains list of patterns some are malformed and some are good, the idea is to process then using regex and identify if some of then are malformed or not.&lt;/P&gt;&lt;P&gt;In Order to check from the _internal I need to first run it&lt;/P&gt;&lt;P&gt;Like - regex "My Pattern"&amp;nbsp; and then i can see there is an error.&lt;/P&gt;&lt;P&gt;But in my case I have a lookup which contains around 300 pattern or so and I need to check if any of those are malformed or not ?I am not sure how to run 300 pattern present in some lookup in one go?&lt;/P&gt;&lt;P&gt;Again, thanks for your response and let me know if you have any queries around my question.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 06:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553783#M157233</guid>
      <dc:creator>tarunmalhotra79</dc:creator>
      <dc:date>2021-06-01T06:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553785#M157234</link>
      <description>&lt;P&gt;Thanks richgalloway for you response.&lt;/P&gt;&lt;P&gt;As of now, it looks like I have to go through the external option (using script) if it is not much time taking or else may be I have to do it manually then.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 06:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553785#M157234</guid>
      <dc:creator>tarunmalhotra79</dc:creator>
      <dc:date>2021-06-01T06:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to identify malformed regex ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553798#M157235</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/207965"&gt;@tarunmalhotra79&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can automate it using Splunk search API's tried as described here got following error.&lt;/P&gt;&lt;P&gt;At a high level you have to iterate through the CSV regex, and execute Splunk search/job API which returns a SID, further passing on SID to results API will provide error/success output.&lt;/P&gt;&lt;P&gt;Alternatively you can reuse py script already written here and improvise as per your need -&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.0/RESTTUT/RESTsearches#Python_example" target="_blank" rel="noopener"&gt;Creating searches using the REST API - Splunk Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;splunk@splunkbox-3:17:03:36:~/bin $ curl -u admin:p*****wrd -k https://localhost:8089/services/search/jobs -d search="| regex \"((hostA.*,hostB.*)\""             &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;response&amp;gt;
  &amp;lt;sid&amp;gt;1622531169.5&amp;lt;/sid&amp;gt;
&amp;lt;/response&amp;gt;
splunk@splunkbox-3:17:06:09:~/bin $ curl -u admin:p*****wrd     -k https://localhost:8089/services/search/jobs/1622531169.5/results/      --get -d output_mode=csv
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;response&amp;gt;
  &amp;lt;messages&amp;gt;
    &amp;lt;msg type="FATAL"&amp;gt;Error in 'SearchOperator:regex': The regex '((hostA.*,hostB.*)' is invalid. Regex: missing closing parenthesis.&amp;lt;/msg&amp;gt;
  &amp;lt;/messages&amp;gt;
&amp;lt;/response&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;----------&lt;/P&gt;&lt;P&gt;An upvote would be appreciated if it helps!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 07:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-identify-malformed-regex/m-p/553798#M157235</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-06-01T07:14:16Z</dc:date>
    </item>
  </channel>
</rss>

