php正则表达式问题??
程序员文章站
2022-06-09 17:29:09
...
$pattern = "/(abcd){1,2}.*(efgh){1,2}/";
$string = "abcd123efgh456";
preg_match_all($pattern,$string,$result);
我这样写会吧abcd和efgh都放到result数组中,我希望把abcd别放到数组里,而把efgh放到数组里,这种pattern怎么写呢?
谢谢
回复内容:
$pattern = "/(abcd){1,2}.*(efgh){1,2}/";
$string = "abcd123efgh456";
preg_match_all($pattern,$string,$result);
我这样写会吧abcd和efgh都放到result数组中,我希望把abcd别放到数组里,而把efgh放到数组里,这种pattern怎么写呢?
谢谢
(?:abcd)