I have a program that takes an input string. I want to delete anything inside the characters ‘<‘ and ‘>’. For example if the string says
"P.S.<!--
BODY
{
color:white;
background-color: transparent;
font-family:sans-serif;
}
--> Hello how are you today?"
I want the output string to only contain "P.S. Hello how are you today?". Is there a simple way to do this in Java? Thanks
Use a regular expression:
What this means is to find every substring beginning with
<, then any number of characters that are not>, and then the character>. Then replace all these substrings with the empty string,"".Reference: java.lang.String.replaceAll()