-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathInputReader.java
More file actions
38 lines (33 loc) · 1010 Bytes
/
InputReader.java
File metadata and controls
38 lines (33 loc) · 1010 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
package io.zipcoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class InputReader {
public String hourRegex(String input ) {
String hours = null;
Pattern pattern = Pattern.compile("\\d*");
Matcher m = pattern.matcher(input);
if(m.find()) {
hours = m.group(0);
}
return hours;
}
public String minuteRegex(String input){
String minutes = null;
Pattern pattern = Pattern.compile(":\\d+");
Matcher matcher = pattern.matcher(input);
if(matcher.find()){
minutes = matcher.group(0);
}
minutes = minutes.substring(1);
return minutes;
}
public String amPmRegex(String input){
String amPm = null;
Pattern pattern = Pattern.compile("[p|a]m", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(input);
if(matcher.find()){
amPm = matcher.group(0);
}
return amPm;
}
}