HR자바 Tag Content Extractor

개요[ | ]

HR자바 Tag Content Extractor
해커랭크 Java
# 문제 비고
HR자바 Strings e
14 HR자바 Java Strings Introduction
15 HR자바 Java Substring
16 HR자바 Java Substring Comparisons
17 HR자바 Java String Reverse
18 HR자바 Java Anagrams
19 HR자바 Java String Tokens
20 HR자바 Pattern Syntax Checker
21 HR자바 Java Regex
22 HR자바 Java Regex 2 - Duplicate Words
23 HR자바 Valid Username Regular Expression
24 HR자바 Tag Content Extractor

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());
        Pattern p = Pattern.compile("<(.+)>([^<]+)</\\1>");
        while(testCases-- > 0) {
            String line = in.nextLine();
            //Write your code here
            Matcher m = p.matcher(line);
            boolean matched = false;
            while( m.find() ) {
                matched = true;
                System.out.println(m.group(2));
            }
            if( !matched ) {
                System.out.println("None");
            }
        }
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}