We are developing an application. In which we get data from the json array. That I want to replace the tag. But the...">

How to replace the tag <br \/">

We are developing an application. In which we get data from the json array. That I want to replace the tag. But the emulator gives an error. As invalid syntax. my code is:

top=top.replaceall("<br\/>"," "); 

Please, help. Thanks in advance...

+4
source share
4 answers

use

 top=top.replaceall("<br\\/>"," "); 

instead

 top=top.replaceall("<br\/>"," "); 

EDIT: Maybe String.relpaceall is not working. therefore, the best way is to use the Matcher regex as:

 Pattern p = Pattern.compile("<br\\/>"); String tempstr = "I love <br/> <br/> <br/> <br/>."; Matcher matcher = p.matcher(tempstr ); String tmp = matcher.replaceAll("Android"); System.out.println(tmp); 

OUTPUT:

"I love Android. Android Android Android."

+8
source

Try it.

 String res = Html.fromHtml(yourString).toString(); 
+4
source

Try it -

 top=top.replaceall("<br\\/>"," "); 
+1
source

the emulator throws an error because top.replaceall ("," ") is wrong,

correctly spelled top.replaceall ("," "), you must use Escape Sequence.

I will try this in my application, this is correct.

0
source

All Articles