php正则表达式不匹配 [英] php regular expression doesn't match

查看:104
本文介绍了php正则表达式不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



PHP'的正则表达式看起来不支持。*?句法。所以我

无法匹配最短的比赛。例如:


$ str =" a1b a3b" ;;

$ str1 = ereg_replace(" a。* b"," peter", $ str1);

将产生peter,但我想要peter peter,那么如何?


谢谢

来自Peter(cm****@hotmail.com)

Hi
PHP''s regular expression look like doesn''t support .*? syntax. So i
cannot match the shortest match. For exmaple:

$str="a1b a3b";
$str1=ereg_replace("a.*b", "peter", $str1);
will produce "peter", but i want "peter peter", so how to?

thanks
from Peter (cm****@hotmail.com)

推荐答案

str =" a1b a3b";
str="a1b a3b";


str1 = ereg_replace(" a。* b"," peter",
str1=ereg_replace("a.*b", "peter",


str1);

会产生peter,但我想要peter peter,所以如何?


感谢
来自Peter的
(cm ** **@hotmail.com)

str1);
will produce "peter", but i want "peter peter", so how to?

thanks
from Peter (cm****@hotmail.com)


这篇关于php正则表达式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆