【发布时间】:2017-06-15 14:35:11
【问题描述】:
我有一个用;#<number>;# 分隔的字符串:
aaaa;#112;#bbbb;#113;#cccc;#112;#dddd
我想使用preg_match() 在数组中查找所有aaaa、bbbb 等。
正则表达式模式应该是什么?
到目前为止我一直在尝试什么:
preg_match('/\;\#(?:[0-9]+)?/', $franchCont, $matches);
【问题讨论】:
-
match?为什么不split?preg_split('/;#\d+;#/', $string) -
@falsetru,是的,它有效,再次感谢 :)
-
我正在尝试:preg_match('/\;\#(?:[0-9]+)?/', $franchCont, $matches);,但 @falsetru 建议的 preg_split为我工作
-
@aniruddha 不要编辑问题以包含答案。答案在页面下方,你应该把它移到那里,或者让 falsetru 把它作为答案发布。
标签: php arrays regex preg-match