You are viewing a single comment's thread. Return to all comments →
Java 8 Solution;
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution{ private static final Pattern TAG_REGEX = Pattern.compile("<(.+)>([^<]+)"); 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(); List<String> tagValues = getTagValues(line); for (String str : tagValues) { System.out.println(str); } testCases--; } } public static List<String> getTagValues(final String str) { final List<String> tagValues = new ArrayList<String>(); final Matcher matcher = TAG_REGEX.matcher(str); if (matcher.find()) { matcher.reset(); while (matcher.find()) { tagValues.add(matcher.group(2)); } //tagValues.add(matcher.group(2)); } else { tagValues.add("None"); } return tagValues; }
}
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 →
Java 8 Solution;
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution{ private static final Pattern TAG_REGEX = Pattern.compile("<(.+)>([^<]+)"); public static void main(String[] args){
}