-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMIL.java
50 lines (41 loc) · 1.24 KB
/
SMIL.java
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
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SMIL {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
scanner.close();
iteration(line);
}
public static void regex(String line) {
String regex = "[:;]-?\\)";
Pattern pattern = Pattern.compile(regex);
Matcher match = pattern.matcher(line);
while (match.find()) {
System.out.println(match.start());
}
}
public static void iteration(String line) {
int lineLength = line.length();
for (int i = 0; i < lineLength; i++) {
if (!(line.charAt(i) == ':' || line.charAt(i) == ';')) {
continue;
}
if (i + 1 >= lineLength) {
break;
}
if (line.charAt(i + 1) == ')') {
System.out.println(i);
i++;
}
if (i + 2 >= lineLength) {
break;
}
if (line.charAt(i + 1) == '-' && line.charAt(i + 2) == ')') {
System.out.println(i);
i+=2;
}
}
}
}