我有一個字符串,我試圖將其拆分為更小的字符串d+\/(任意數字后跟 a /)。這是我的字符串:2/ This is a string that has some words on a new line3/ This is another string that might also have some words on a new line到目前為止,我正在使用這段代碼:$re = '/\d+\/\s+.*/';$str = '2/ This is a string that has some words on a new line3/ This is another string that might also have some words on a new line';preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);但問題是,對于第一場比賽,我只得到第一行:[Match 1] 2/ This is a string[Match 2] 3/ This is another string that might also have some words on a new line我怎樣才能讓所有的行都匹配到d+\/或直到整個字符串/文本的末尾?期望的結果:[Match 1] 2/ This is a string that has some words on a new line[Match 2] 3/ This is another string that might also have some words on a new line
- 1 回答
- 0 關注
- 140 瀏覽
添加回答
舉報
0/150
提交
取消