我的字符串頁面包含此頁面http://www.posh24.se/kandisar,我想提取兩者之間的所有內(nèi)容<div class="channelListEntry"> 和</div>并將結(jié)果放入ArrayList.東西matcher.find()總是有回報(bào)的false。private ArrayList<String> extracted = new ArrayList<String>(); public void extractChannel(String htmlPage){ Pattern pattern = Pattern.compile("<div class=\"channelListEntry\">(.*?)</div>"); Matcher matcher = pattern.matcher(htmlPage); while(matcher.find()){ // Always return false System.out.println("hello ?"); extracted.add(matcher.group(1)); }}我希望在我的數(shù)組中的標(biāo)簽之間復(fù)制文本。
1 回答

撒科打諢
TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊
編譯模式時(shí)添加 Pattern.DOTALL 標(biāo)志,使其匹配多行 - https://stackoverflow.com/a/2913756/9335036
添加回答
舉報(bào)
0/150
提交
取消