- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0026.java
More file actions
Latest commit
36 lines (27 loc) · 788 Bytes
/
Copy pathHackerrankJava0026.java
File metadata and controls
36 lines (27 loc) · 788 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
importjava.util.Scanner;
importjava.util.regex.Matcher;
importjava.util.regex.Pattern;
publicclassHackerrankJava0026 {
publicstaticvoidmain(String[] args) {
// Tag Content Extractor
// https://www.hackerrank.com/challenges/tag-content-extractor/problem?isFullScreen=true
StringtagRegex = "<(.+)>([^<]+)<\\/\\1>";
Patternpattern = Pattern.compile(tagRegex);
Scannerin = newScanner(System.in);
inttestCases = Integer.parseInt(in.nextLine());
while (testCases > 0) {
Stringline = in.nextLine();
booleanfound = false;
Matchermatcher = pattern.matcher(line);
while (matcher.find()) {
found = true;
System.out.println(matcher.group(2));
}
if (!found) {
System.out.println("None");
}
testCases--;
}
in.close();
}
}