-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagContentExtractor.java
More file actions
38 lines (27 loc) · 909 Bytes
/
Copy pathTagContentExtractor.java
File metadata and controls
38 lines (27 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
String expression = "<([^<>]+)>([^<>]+)</\\1>";
Pattern pattern = Pattern.compile(expression);
int testCases = Integer.parseInt(in.nextLine());
while(testCases>0){
String line = in.nextLine();
//Write your code here
Matcher matcher = pattern.matcher(line);
int count = 0;
while (matcher.find() == true){
System.out.println(matcher.group(2));
count++;
}
if (count == 0) {
System.out.println("None");
}
testCases--;
}
}
}