Bug #77827 [Opn]: preg_match throws error on valid expression
| From: | peehaa@php.net | Date: | Sat, 30 Mar 2019 20:16:47 +0000 |
| Subject: | Bug #77827 [Opn]: preg_match throws error on valid expression | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220258@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77827&edit=1
ID: 77827
Updated by: peehaa@php.net
Reported by: peehaa@php.net
Summary: preg_match throws error on valid expression
Status: Open
Type: Bug
Package: PCRE related
Operating System: Windows
PHP Version: 7.3.3
Block user comment: N
Private report: N
New Comment:
Nope. Same result. When I check a hex dump of my file I also do not see anything strange at first
sight.
Previous Comments:
------------------------------------------------------------------------
[2019-03-30 19:43:03] requinix@php.net
Works for my 7.3.3 on Windows. Does it work if you copy/paste the code from this bug report? Is
there maybe a stray unprintable character in your file?
------------------------------------------------------------------------
[2019-03-30 19:37:24] peehaa@php.net
Weirdly enough when I use a single line pattern it starts working:
<?php
$pattern =
'~^(?:(?:(?P<function>function)\s*\(\s*(?:(?P<table1>.+)(?:\.))?(?P<column1>[^
]+)\s*\))|(?:(?P<table2>.+)(?:\.))?(?P<column2>[^
]+))(?:\s+as\s+(?P<alias>.+))?$~ix';
var_dump(PCRE_VERSION);
var_dump(preg_match($pattern, 'id'));
var_dump(preg_last_error());
-----
string(16) "10.32 2018-09-10"
int(1)
int(0)
Am I doing something wrong here in combination with the platform I am on somehow?
------------------------------------------------------------------------
[2019-03-30 17:49:26] peehaa@php.net
Description:
------------
When running the repro script on my machine I am hitting two issues:
1. preg_match is unable to handle my valid expression
2. it outputs a broken error message
This only happens on my (Windows) machine. On 3v4l (https://3v4l.org/hdiM4) it's working like
it should.
Test script:
---------------
<?php
$pattern = '
~^
(?:
(?:(?P<function>function)\s*\(\s*
(?:(?P<table1>.+)(?:\.))?(?P<column1>[^ ]+)
\s*\))
|
(?:(?P<table2>.+)(?:\.))?(?P<column2>[^ ]+)
)
(?:\s+as\s+(?P<alias>.+))?
$~ix
';
var_dump(PCRE_VERSION);
var_dump(preg_match($pattern, 'id'));
var_dump(preg_last_error());
Expected result:
----------------
string(16) "10.32 2018-09-10"
int(1)
int(0)
Actual result:
--------------
string(16) "10.32 2018-09-10"
' in \path\to\php-bug.php on line 17
bool(false)
int(1)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77827&edit=1