|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46890 Regex works in perl, not with preg_match
Submitted: 2008-12-17 20:51 UTC Modified: 2008-12-18 11:51 UTC
From: gohanman at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.8 OS: CentOS
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:
Solve the problem:
17 + 46 = ?
Subscribe to this entry?

 [2008-12-17 20:51 UTC] gohanman at gmail dot com
I'm having a preg_match function fail periodically. I finally found a specific input string that fails in PHP but works fine in Perl. I'm at a loss why.

Reproduce code:
$pattern = "/(\w\w\w) (\d+) (\d\d\d\d) (\d+):(\d\d)(\w)M/";
$input = "Dec 17 2008 2:23PM";
$rv = preg_match($pattern, $input, $groups);
echo var_dump($rv);

Expected result:
A non-zero result indicating the pattern matched.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 08:50 UTC] php at degoulet dot net
[root@pix root]# cat a.php 
$pattern = "/(\w\w\w) (\d+) (\d\d\d\d) (\d+):(\d\d)(\w)M/";
$input = "Dec 17 2008 2:23PM";
$rv = preg_match($pattern, $input, $groups);
echo var_dump($rv);

[root@pix root]# php -v
PHP 5.2.8 (cli) (built: Dec 17 2008 16:18:21) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

[root@pix root]# php a.php 
 [2008-12-18 11:51 UTC]
it works here.
try to do a var_dump($groups); and watch it closely. (btw you shouldn't do 'echo var_dump'..)
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 02:05:45 2022 UTC