php.net |  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
Description:
------------
The regexs for preg_match() are suppose to work, but error occur

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

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

Expected result:
----------------
//test1.php - expected result
1

//test2.php - expected result
1

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
0

Patches

Pull Requests

History

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

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC