Re: preg match compilation error
| From: | Marek Kilimajer | Date: | Mon, 27 Oct 2003 20:10:54 +0000 |
| Subject: | Re: preg match compilation error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167807@lists.php.net to get a copy of this message | ||
Do you realy want to use [ and ] as patern delimiters? My quess is that you want to use it for defining character class. Then the only character that must be escaped is -
'/[^a-z0-9,._+()\-]/i'
Luis Lebron wrote:
I found a reqular expresion that I'm using to check for valid characters in file names. Here's the sample code: if(preg_match("[^a-zA-Z0-9,._\+\()\-]",$filename)) { //blah, blah, blah } However, when I run the script I get the following error: Warning: Compilation failed: unmatched parentheses at offset 17 in /home/httpd/sigmarapid/html/test/upload.php on line 137 (the line with the preg_match) I'm new to regular expressions so any help would be greatly appreciated. Luis R. Lebron Sigmatech, Inc