-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathFormater.java
More file actions
48 lines (37 loc) · 1.54 KB
/
Formater.java
File metadata and controls
48 lines (37 loc) · 1.54 KB
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
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Formater {
public String[] splitItems() {
Pattern pattern = Pattern.compile("##");
String[] items = pattern.split(replaceApples());
return items;
}
public String replaceApples () {
String rText = replaceBread();
Pattern applePattern = Pattern.compile("(apples)", Pattern.CASE_INSENSITIVE);
Matcher appleMatcher = applePattern.matcher(rText);
String appleFormat = appleMatcher.replaceAll("Apples");
return appleFormat;
}
public String replaceBread () {
String rText = replaceCookies();
Pattern breadPattern = Pattern.compile("(bread)", Pattern.CASE_INSENSITIVE);
Matcher breadMatcher = breadPattern.matcher(rText);
String breadFormat = breadMatcher.replaceAll("Bread");
return breadFormat;
}
public String replaceCookies () {
String rText = replaceMilk();
Pattern cookiePattern = Pattern.compile("(cookies)|(Co0kieS)", Pattern.CASE_INSENSITIVE);
Matcher cookieMatcher = cookiePattern.matcher(rText);
String cookieFormat = cookieMatcher.replaceAll("Cookies");
return cookieFormat;
}
public String replaceMilk () {
String rText = Main.readRawDataToString();
Pattern milkPattern = Pattern.compile("(milk)|(Milk)", Pattern.CASE_INSENSITIVE);
Matcher milkMatcher = milkPattern.matcher(rText);
String milkFormat = milkMatcher.replaceAll("Milk");
return milkFormat;
}
}