You are viewing a single comment's thread. Return to all comments →
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()); String tagContentRegex = "<([\\s\\S_ ]+)>([^<>]+)</\\1>"; Pattern tagPattern = Pattern.compile(tagContentRegex); while (testCases>0) { String line = in.nextLine(); boolean found = false; Matcher matcher = tagPattern.matcher(line); while (matcher.find()) { String content = matcher.group(2); System.out.println(content); found = true; } if (!found) { System.out.println("None"); } testCases--; } in.close(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tag Content Extractor
You are viewing a single comment's thread. Return to all comments →