正则表达式中是否有任何方法可以匹配2个案例 我得到了这个文件,例如
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$1
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$1
我想匹配它
开始时bfcb918c5343aaaf2100856c992aa6aa
最后1
答案 0 :(得分:4)
在编辑了他的问题之后,我想我明白他需要做什么:
<?php
$str = "
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$1
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$0
bfcb918c5343aaaf2100856c992aa6aa$-$Bahaa$-$WTB$-$CH$-$11$-$Glavie$-$None$-$SOS$-$1Mil$-$2012-01-28 09:15:02$-$1";
preg_match_all('/^bfcb918c5343aaaf2100856c992aa6aa(.*?)1$/im', $str, $matches);
print_r($matches);
示例输出:
阵列( [0] =&gt;排列 ( [0] =&gt; bfcb918c5343aaaf2100856c992aa6aa $ - $ - $ - $ - $ $ 11 - $ - $ - $ - $ 1mil的$ - $ 2012-01-28 9时15个02秒$ - 新台币$ 30 [1] =&gt; bfcb918c5343aaaf2100856c992aa6aa $ - $ - $ - $ - $ $ 11 - $ - $ - $ - $ 1mil的$ - $ 2012-01-28 9时15个02秒$ - 新台币$ 30 )
[1] => Array ( [0] => $-$-$-$-$11$-$-$-$-$1Mil$-$2012-01-28 09:15:02$-$ [1] => $-$-$-$-$11$-$-$-$-$1Mil$-$2012-01-28 09:15:02$-$ )
)