|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-03-01 12:03 UTC] cmb@php.net
-Package: Unknown/Other Function
+Package: PCRE related
[2018-03-01 12:03 UTC] cmb@php.net
[2018-03-01 13:12 UTC] master at hiroz dot cn
[2018-03-06 18:12 UTC] jhdxr@php.net
[2018-03-07 01:37 UTC] master at hiroz dot cn
[2018-03-07 01:38 UTC] master at hiroz dot cn
[2018-03-08 13:52 UTC] jhdxr@php.net
-Status: Open
+Status: Not a bug
[2018-03-08 13:52 UTC] jhdxr@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 15:00:01 2025 UTC |
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 }}} ) )