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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 22 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 17:05:44 2022 UTC