I know of using this:
public String RemoveTag(String html){
html = html.replaceAll("\\<.*?>","");
html = html.replaceAll(" ","");
html = html.replaceAll("&","");
return html;
}
This removes all tags within an html string. However the question is how does it get a wild characters in between <.*?>. Could someone give me a more detailed explanation on how getting wild characters in String.
The main reason for this is that I still have this characters that has “an @ at start point and } at end point” and I want to get rid of everything in between "@" and "}".
The first parameter to replaceAll(…) is a regex string. The
.*?in your example is the part that matches anything. So, if you want a regular expression that will get rid of everything between “@” and “}” you would use something like:Notice the same pattern:
.*?. The parentheses, which are optional here, are just used for grouping. Also notice the}is escaped with backslashes since it can have special meaning within regular expressions.For more info on Java’s regex support see the Pattern class.