Tag Content Extractor

윤지현·2025년 5월 1일
0

HackerRank[Java]

목록 보기
52/57
  • 문제
  • 정답
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution{
	public static void main(String[] args){
		
		Scanner in = new Scanner(System.in);
		int testCases = Integer.parseInt(in.nextLine());
		while(testCases>0){
			String line = in.nextLine();
			
          	boolean found = false;
            
            Pattern pattern = Pattern.compile("<([^<>]+)>([^<>]+)</\\1>");
            Matcher matcher = pattern.matcher(line);
            
            while(matcher.find()) {
                System.out.println(matcher.group(2));
                found = true;
            }
            
            if(!found) {
                System.out.println("None");
            }
			
			testCases--;
		}
	}
}
  • 결과
profile
첫 시작

0개의 댓글