You are viewing a single comment's thread. Return to all comments →
import javax.swing.text.StyledEditorKit; 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 pattern = Pattern.compile("<(.+)>([^<>]+)</\\1>"); for (int i = 0; i < testCases; i++) { boolean matched = false; String string = in.nextLine(); Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println(matcher.group(2)); matched = true; } if (!matched) { System.out.println("None"); } } } }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Tag Content Extractor
You are viewing a single comment's thread. Return to all comments →