Program to remove HTML tags from a given String | Java program for the above approach ; Function to remove the HTML tags from the given tags ; Use replaceAll function in regex to erase every tags enclosed in < > ; Print string after removing tags ; Driver Code ; Given String ; Function call to print the HTML string after removing tags
class GFG { static void RemoveHTMLTags ( String str ) { str = str . replaceAll ( " \\ < . * ? \\ > " , " " ) ; System . out . println ( str ) ; } public static void main ( String [ ] args ) { String str ; str = " < div > < b > Geeks ▁ for ▁ Geeks < / b > < / div > " ; RemoveHTMLTags ( str ) ; } }