【发布时间】:2020-09-10 08:51:30
【问题描述】:
任何想法为什么这个 preg_match 可以在 PHP7.2 上运行,但在 7.3+ 上失败?
$word = 'umweltfreundilch'; //real life example :/
preg_match('/^(?U)(.*(?:[aeiouyäöü])(?:[^aeiouyäöü]))(?X)(.*)$/u', $word, $matches);
var_dump($matches);
警告:preg_match():编译失败:在 (? 或 (?-
PHP 7.2 及以下输出:
array(3) {
[0]=>
string(16) "umweltfreundilch"
[1]=>
string(2) "um"
[2]=>
string(14) "weltfreundilch"
}
RegEx 似乎没问题,不是吗?
https://regex101.com/r/LGdhaM/1
【问题讨论】:
-
在正则表达式中没有
äöü是否可以工作? -
不,同样的错误。 sry 应该提到... :)
标签: php regex preg-match