我想分割一個包含正常文本的字符串以及html代碼到字符串數組中。我試圖搜索谷歌,但沒有找到任何合適的建議。單獨的html編碼字符串和普通字符串
考慮以下字符串:
blahblahblahblahblahblahblahblahblahblah
blahblah首先對blahblahblahblah
blahblahblahblahblahblahblahblahblahblah<html> <body> <p>hello</p> </body> </html>
blahblahblahblahblahblahblahblahblahblah
blahblah二帕拉lahblahblahblahblah
blahblahblahblahblahblahblahblahblahblah
變爲:
s[0]=whole first para
s[1]=html code
s[2]=whole second para
是否有可能通過jsoup
?或者我需要其他API?
你能不能簡單地搜索和標籤? – Floris
我的字符串並不總是包含html標籤字符串也可以只包含body標籤或任何其他html標籤 –
有沒有像你的例子一樣有一個字符串結構的好理由? – KarelG