|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51438 First arg of preg_match()
Submitted: 2010-03-30 14:01 UTC Modified: 2010-03-30 14:14 UTC
From: abca_b_cabcom at hotmail dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 5.3.2 OS: Windows 7
Private report: No CVE-ID: None
 [2010-03-30 14:01 UTC] abca_b_cabcom at hotmail dot com
The regexs for preg_match() are suppose to work, but error occur

Test script:
echo preg_match("/^(([A-Z][a-z]*)+\\)*([A-Z][a-z]*)+$/", 'Plz\TestMe');

echo preg_match("/^(([A-Z][a-z]*)+[\\])*([A-Z][a-z]*)+$/", 'Plz\TestMe');

Expected result:
//test1.php - expected result

//test2.php - expected result

Actual result:
//test1.php - actual result
Warning: preg_match() [function.preg-match]: Compilation failed: missing ) at offset 34 in path\to\test.php on line 3

//test2.php - actual result


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-30 14:14 UTC]
-Status: Open +Status: Bogus
 [2010-03-30 14:14 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

echo "/^(([A-Z][a-z]*)+[\\])*([A-Z][a-z]*)+$/";

And see what you pass to the regexp engine. You're using " so \\] becomes \] which escapes the ]  ...
 [2010-03-30 14:26 UTC] abca_b_cabcom at hotmail dot com
Yeah got you, johannes, thx

Sorry, it is now a bug for both case, but looks strange for the protocol of regex.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 17:01:30 2023 UTC