我需要某種方式來捕獲方括號(hào)之間的文本。因此,例如,以下字符串:[This] is a [test] string, [eat] my [shorts].可用于創(chuàng)建以下數(shù)組:Array ( [0] => [This] [1] => [test] [2] => [eat] [3] => [shorts] )我有以下正則表達(dá)式,/\[.*?\]/但它僅捕獲第一個(gè)實(shí)例,因此:Array ( [0] => [This] )如何獲得所需的輸出?請(qǐng)注意,方括號(hào)是從不嵌套的,因此不必?fù)?dān)心。
2 回答

MM們
TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊
奇怪的是,我現(xiàn)在得到以下信息:Array ( [0] => Array ( [0] => [This] [1] => [test] [2] => [eat] [3] => [shorts] ) [1] => Array ( [0] => This [1] => test [2] => eat [3] => shorts ) )
- 2 回答
- 0 關(guān)注
- 618 瀏覽
添加回答
舉報(bào)
0/150
提交
取消