0
我遇到了我的正則表達式問題。
我的正則表達式只返回來自文本的第一個單詞。我想從這個字符串中返回所有的單詞。正則表達式僅返回文本中的第一個單詞
正則表達式:
$test = "Reason: test test test";
$regex = "/Reason: (\w+)+/";
preg_match_all($regex, $test, $reason);
從
的var_dump($原因)
返回代碼:
array(2) {
[0]=>
array(1) {
[0]=>
string(12) "Reason: test"
}
[1]=>
array(1) {
[0]=>
string(4) "test"
}
}
我想:
array(2) {
[0]=>
array(1) {
[0]=>
string(12) "Reason: test test test"
}
[1]=>
array(1) {
[0]=>
string(4) "test test test"
}
}
'* $'? .................. – zerkms
感謝您的解決方案@zerkms,這是我需要的。 – exexe