0

hi I have input as follows:

"Java technology's versatility, efficiency, <br/> <br/> platform portability, and security make it the ideal technology for network computing. <div/>"

I want to remove <br/> & <div/> tag from above input.And I want output as follows: Output:-"Java technology's versatility, efficiency, platform portability, and security make it the ideal technology for network computing."

Please help me how to remove these tags,What will be the java code to get above output?

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
DJ31
  • 1,219
  • 3
  • 14
  • 19

3 Answers3

3

Use JSoup Cleaner to remove HTML stuff.

Example :

String unsafe = "your string containing html";
String safe = Jsoup.clean(unsafe, Whitelist.basic());
jmj
  • 237,923
  • 42
  • 401
  • 438
2

You can try

String unsafe = "Java technology's versatility, efficiency, <br/> <br/> platform portability, and security make it the ideal technology for network computing. <div/>";
String safe = unsafe.replaceAll("<[^>]+>", "")
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • @DJ31, once you have given people enough time to answer and you have a solution you like, you can accept one of them. (Find the tick under the vote number on the left) ;) – Peter Lawrey May 02 '11 at 12:32
0

Go for htmlParser.

Lots of helping hand :

Community
  • 1
  • 1
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164