kalpana c
kalpana c

Reputation: 2739

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

I want to replace html tag to another tag 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><");
}

Upvotes: 1

Views: 1146

Answers (1)

kalpana c
kalpana c

Reputation: 2739

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><");
}

Upvotes: 1

Related Questions