Bug #76033 [Opn]: some words, preg_match_all can't match big S correctly

From: Date: Wed, 07 Mar 2018 01:37:18 +0000
Subject: Bug #76033 [Opn]: some words, preg_match_all can't match big S correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214228@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76033&edit=1

 ID:                 76033
 User updated by:    master at hiroz dot cn
 Reported by:        master at hiroz dot cn
 Summary:            some words, preg_match_all can't match big S
                     correctly
 Status:             Open
 Type:               Bug
 Package:            PCRE related
 Operating System:   macOS 10.12.6
 PHP Version:        5.6.33
 Block user comment: N
 Private report:     N

 New Comment:

I reproduce it in 5.4~5.6.33 in macOS. In Linux all versions works fine.

In macOS, 5.7 works fine too.

If these versions only received in security support, I think it can be ignored.


Previous Comments:
------------------------------------------------------------------------
[2018-03-06 18:12:20] jhdxr@php.net

I cannot reproduce this bug as well.

In addition, did you try php 7.1 or above? 5.6 only received in security support.

------------------------------------------------------------------------
[2018-03-01 13:12:54] master at hiroz dot cn

please try it in macOS again.

------------------------------------------------------------------------
[2018-03-01 12:03:27] cmb@php.net

I cannot reproduce the described behavior:
<https://3v4l.org/UeP92>.

------------------------------------------------------------------------
[2018-03-01 03:29:10] master at hiroz dot cn

Description:
------------
preg_match_all can't match \S correctly

in php5.4 ~ php5.6.33

```
$matches = array();
$template = '<p>{{{ 发货单号 }}}</p><p>{{{
单据123号 }}}</p><p>{{{ 拉包 }}}</p><p>{{{ a
}}}</p><p>{{{ a }}}</p>';
$ret = preg_match_all('/\{\{\{ \S+ \}\}\}/', $template, $matches);
print_r($matches);
```

result is 
```
Array
(
    [0] => Array
        (
            [0] => {{{ 发货单号 }}}
            [1] => {{{ 单据123号 }}}
            [2] => {{{ a }}}
            [3] => {{{ a }}}
        )

)
```

the "拉包" is missing. i try many cases. "包" can't be matched
by "\S".

but in php5.3 or other languages, "包" can be matched by "\S".




Test script:
---------------
$matches = array();
$template = '<p>{{{ 发货单号 }}}</p><p>{{{
单据123号 }}}</p><p>{{{ 拉包 }}}</p><p>{{{ a
}}}</p><p>{{{ a }}}</p>';
$ret = preg_match_all('/\{\{\{ \S+ \}\}\}/', $template, $matches);
print_r($matches);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [0] => {{{ 发货单号 }}}
            [1] => {{{ 单据123号 }}}
            [2] => {{{ 拉包 }}}
            [3] => {{{ a }}}
            [4] => {{{ a }}}
        )

)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [0] => {{{ 发货单号 }}}
            [1] => {{{ 单据123号 }}}
            [2] => {{{ a }}}
            [3] => {{{ a }}}
        )

)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76033&edit=1


Thread (7 messages)

« previous php.bugs (#214228) next »