I'm trying to filter a string and keep only certain phrases, trying to develop an amateur syntax checker for code. For example:
String line = "<html><head><title>HELLO WORLD</title></head><body>Hello WorldMy name is Ricardo i hope you are all doing good</body></html>";
String[] splitt = line.split("\\<html>|\\</html>|\\<head>|\\</head>|\\<title>|\\</title>|\\<body>|\\</body>");
for (String split: splitted) {
System.out.println(split);
}
}
I want to take all the tokens such as <html>
, </html>
, <title>
, </title>
and with the code up there I'm getting totally the opposite, basically filtering out what I want.
Thanks in advance! I've been stressing out all day trying to figure it out.