Krishnendu Ghosh
Krishnendu Ghosh

Reputation: 334

I need to replace a String in java based on patterns

I want to remove everything between a html tag named "code" from a string named "answer". My code is as follows:

answer = answer.replaceAll("<code>*</code>","");

It is not working. Please help.

Upvotes: 1

Views: 52

Answers (1)

Krishnendu Ghosh
Krishnendu Ghosh

Reputation: 334

answer = answer.replaceAll("(?s)<code>.*?</code>","");

Upvotes: 1

Related Questions