【发布时间】:2017-10-19 01:25:09
【问题描述】:
正则表达式会突出显示错误的词,例如 Hell«o»,而忽略正确的词 «Hello» 或 Hello,
所以,我的问题对于我的 javascript 代码来说工作得很好,但是当我为 php 尝试它时,它也会突出显示字符串,这不应该:
- '«这是销售点»';
这是我的正则表达式:https://regex101.com/r/SqCR1y/14
PHP 代码:
$re = '/^(?:.*[[{(«][^\]})»\n]*|[^[{(«\n]*[\]})»].*|.*\w[[{(«].*|.*[\]})»]\w.*)$/m';
$str = '«This is the point of sale»';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
//输出
array(1) {
[0]=>
array(1) {
[0]=>
string(29) "«This is the point of sale»"
}
}
预期:空数组
jsfiddle 在这里,工作正常
提前致谢
【问题讨论】:
标签: php regex preg-match-all