向前预查
只匹配x后面不是y的x。
有点拗口,请看例子。为区别起见增加里忽略大小写
<?php
$str = 'xyzXp';
preg_match("/x(?!y)/i",$str,$regs);
print_r($regs);
?>
可见只匹配了X
若
<?php
$str = 'xyzXp';
preg_match("/x(?=y)/i",$str,$regs);
print_r($regs);
?>
则只匹配了x
只匹配x后面不是y的x。
有点拗口,请看例子。为区别起见增加里忽略大小写
<?php
$str = 'xyzXp';
preg_match("/x(?!y)/i",$str,$regs);
print_r($regs);
?>
可见只匹配了X
若
<?php
$str = 'xyzXp';
preg_match("/x(?=y)/i",$str,$regs);
print_r($regs);
?>
则只匹配了x
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货