我問的問題關於正則表達式替換引用,不帶引號,引用,不帶引號的......在這個線程情況:Regex for quote tags php報價標籤的正則表達式PHP - 一般情況下
我意識到我需要保存的物品訂購更一般的情況。如引用,不加引號,引用,引用,引用等等......還有沒有嵌套引號。我想它應該做迭代或遞歸...我會解釋一下例子。
some unquoted text11
[quote="person1"]some quoted text11[/quote]
[quote="person2"]some quoted text22[/quote]
[quote="person3"]some quoted text33[/quote]
some unquoted text22
...
[quote="person4"]some quoted text44[/quote]
...
結果數組應該是:
Array //PRESERVED ORDER
(
[0] => Array
(
['type'] => unquoted
['name'] => ''
['text'] => some unquoted text11
)
[1] => Array
(
['type'] => quoted
['name'] => person1
['text'] => some quoted text11
)
[2] => Array
(
['type'] => quoted
['name'] => person2
['text'] => some quoted text22
)
[3] => Array
(
['type'] => quoted
['name'] => person3
['text'] => some quoted text33
)
[4] => Array
(
['type'] => unquoted
['name'] => ''
['text'] => some unquoted text22
)
...
[5] => Array
(
['type'] => quoted
['name'] => person4
['text'] => some quoted text44
)
...
}
嘿,你告訴我們你試過什麼? – HamZa