开发者

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

开发者 https://www.devze.com 2023-04-12 18:47 出处:网络
I want to replace html tag to another ta开发者_运维技巧g like this: for (int i = 1; i <= htmlarray.size(); i++)

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

精彩评论

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