문제는 매우 간단하지만 설명이 미숙했다.
처음에는 특정 꺽쇠만 존재하는 줄 알았다만,, 모든 꺽쇠가 가능했던것! -> 이것은 정규식으로 해결가능하였다.
package BOJ.IP;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class G22859 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void check(String str) {
// 공백제거
str = str.trim();
// 태그 지우기
str = str.replaceAll("<[^<>]+>","");
str = str.replaceAll(" {2,}"," ");
System.out.println(str);
}
public static void main(String[] args) throws IOException {
String str = br.readLine();
//main 걸러내기
String[] arr = str.split("<main>|</main>");
Queue<String> queue = new LinkedList<>();
for (int i = 0; i < arr.length; i++) {
if(arr[i] != "") {
String[] tmp = arr[i].split("<div title=\"|\">|</div>");
for (int j = 0; j < tmp.length; j++) {
if(tmp[j] != "") {
queue.add(tmp[j]);
}
}
}
}
while(!queue.isEmpty()) {
String[] tmp = queue.poll().split("<p>|</p>");
if(tmp.length == 1) {
System.out.println("title : " + tmp[0]);
}else {
for (int i = 0; i < tmp.length; i++) {
if(tmp[i]!="") {
check(tmp[i]);
}
}
}
}
}
}
구냥 정규식 잘쓰면 됬던 문제~ 별로 좋은문제는 아닌듯..