You are viewing a single comment's thread. Return to all comments →
java solution
import java.io.*; import java.util.*; import java.util.regex.Pattern; import java.util.regex.Matcher; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = Integer.parseInt(scanner.nextLine()); Pattern pattern = Pattern.compile("<a href=\"(\\S+)\"[^>]*>([^<]*)(</a>){0,1}(<(\\w+)>){0,1}([^<>]+){0,1}(</\\5>){0,1}(</a>){0,1}"); for (int i = 0; i < n; i++) { Matcher m = pattern.matcher(scanner.nextLine()); while (m.find()) System.out.println(m.group(1) + "," + (((m.group(6) == null) || (m.group(2) != "")) ? m.group(2).trim() : m.group(6))); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Detect HTML links
You are viewing a single comment's thread. Return to all comments →
java solution