开发者

Replace html string/tag to another html string/tag android

I want to replace html tag to another ta开发者_运维技巧g like this:

for (int i = 1; i <= htmlarray.size(); i++) 
{
    Content = Content.replaceAll("<Sup><FONT size=\"+1\">" + i+ "<","<Sup><FONT size=\"+2\"><a style=\"color: #664b38\"href=\"http:/"+ i + "\">" + i + "</a><");
}


I got my answer and here it is:

public String replace(CharSequence target, CharSequence replacement) {
return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(target).replaceAll(Matcher.quoteReplacement(replacement.toString()));
}

This function worked for me. And also using replace() function.

for (int i = 1; i <= htmlarray.size(); i++) 
{
 Content = Content.replace("<Sup><FONT size=\"+1\">" + i+ "<","<Sup><FONT size=\"+2\"><a style=\"color: #664b38\"href=\"http:/"+ i + "\">" + i + "</a><");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜