<?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 error in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-error/m-p/153958#M43254</link>
    <description>&lt;P&gt;The characters ( and ) in regex are used for grouping so you need to escape them if you want to match literally.&lt;BR /&gt;
You can also use &lt;CODE&gt;\d&lt;/CODE&gt; for digit, I find it more readable than [0-9].&lt;BR /&gt;
Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;m/\(\d\d\d\)\s*\d\d\d-\d\d\d\d/ 
m/\(\d{3}\)\s*\d{3}-\d{4}/
m/\(\d+\)\s*\d+-\d+/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;depending on whether you want to exactly match the number of digits and preference of style. &lt;/P&gt;</description>
    <pubDate>Sat, 23 Nov 2013 23:07:25 GMT</pubDate>
    <dc:creator>tpflicke</dc:creator>
    <dc:date>2013-11-23T23:07:25Z</dc:date>
    <item>
      <title>Regex error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-error/m-p/153957#M43253</link>
      <description>&lt;P&gt;I am trying to validate that the user has entered their phone number in this format (555) 555-5555. I keep getting this error: Unmatched ) in regex; marked by &amp;lt;-- HERE in m/[([0-9]) &amp;lt;-- HERE ]+[[0-9]-]+[[0-9]+/ at validate.cgi line 46. My code is below. Any help?&lt;/P&gt;

&lt;P&gt;sub validate_input {&lt;BR /&gt;
my $valid = "Y";&lt;BR /&gt;
my $errormsg;&lt;BR /&gt;
if ($phone !~ m/[([0-9])]+[[0-9]-]+[[0-9]+/]) {&lt;BR /&gt;
$valid = "N";&lt;BR /&gt;
my $errormsg = "enter a valid phone number in format desired.";&lt;BR /&gt;
}&lt;BR /&gt;
return $valid, $errormsg;&lt;BR /&gt;
}&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2013 21:06:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-error/m-p/153957#M43253</guid>
      <dc:creator>Puzzle2011</dc:creator>
      <dc:date>2013-11-23T21:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex error</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-error/m-p/153958#M43254</link>
      <description>&lt;P&gt;The characters ( and ) in regex are used for grouping so you need to escape them if you want to match literally.&lt;BR /&gt;
You can also use &lt;CODE&gt;\d&lt;/CODE&gt; for digit, I find it more readable than [0-9].&lt;BR /&gt;
Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;m/\(\d\d\d\)\s*\d\d\d-\d\d\d\d/ 
m/\(\d{3}\)\s*\d{3}-\d{4}/
m/\(\d+\)\s*\d+-\d+/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;depending on whether you want to exactly match the number of digits and preference of style. &lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2013 23:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-error/m-p/153958#M43254</guid>
      <dc:creator>tpflicke</dc:creator>
      <dc:date>2013-11-23T23:07:25Z</dc:date>
    </item>
  </channel>
</rss>

