Donate : Link
Medium Blog : Link
Applications : Link
GetHTMLTags.java
package com.codeFactory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GetHTMLTags {
public static void main(String... args) throws IOException {
Pattern pattern = Pattern.compile("<([^\\s>/]+)");
Matcher matcher = pattern.matcher(getHTML());
while(matcher.find()) {
System.out.println(matcher.group(1));
}
}
private static String getHTML() throws IOException {
return new String(Files.readAllBytes(Paths.get("TestHTML.html")));
}
}
TestHTML.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output :
!DOCTYPE
html
head
title
body
h1
p


Like!! Great article post.Really thank you! Really Cool.
LikeLike
Thank you…
Please check new blog https://bit.ly/31989Yt
LikeLike