DJ31
DJ31

Reputation: 1239

having issue with string in java

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?

Upvotes: 0

Views: 142

Answers (3)

Peter Lawrey
Peter Lawrey

Reputation: 533492

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("<[^>]+>", "")

Upvotes: 2

Jigar Joshi
Jigar Joshi

Reputation: 240870

Use JSoup Cleaner to remove HTML stuff.

Example :

String unsafe = "your string containing html";
String safe = Jsoup.clean(unsafe, Whitelist.basic());

Upvotes: 3

Related Questions