|
@@ -37,23 +37,20 @@ public class HamletParser {
|
37
|
37
|
}
|
38
|
38
|
|
39
|
39
|
private Matcher matchingwords(String regex){
|
40
|
|
- Pattern pattern = Pattern.compile(regex);
|
41
|
|
- Matcher matcher = pattern.matcher(this.hamletData.toLowerCase());
|
|
40
|
+ Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
|
41
|
+ Matcher matcher = pattern.matcher(this.hamletData);
|
42
|
42
|
return matcher;
|
43
|
43
|
}
|
44
|
44
|
|
45
|
45
|
public void changeHamletToLeon() {
|
46
|
|
- if(findHamlet()) {
|
47
|
|
- Matcher matcher = matchingwords("Hamlet");
|
48
|
|
- matcher.replaceAll("Leon");
|
49
|
|
- }
|
|
46
|
+
|
|
47
|
+ Matcher matcher = matchingwords("hamlet");
|
|
48
|
+ hamletData = matcher.replaceAll("Leon");
|
50
|
49
|
}
|
51
|
50
|
|
52
|
51
|
public void changeHoratioToTariq() {
|
53
|
|
- if(findHamlet()) {
|
54
|
|
- Matcher matcher = matchingwords("Horatio");
|
55
|
|
- matcher.replaceAll("Tariq");
|
56
|
|
- }
|
|
52
|
+ Matcher matcher = matchingwords("horatio");
|
|
53
|
+ hamletData = matcher.replaceAll("Tariq");
|
57
|
54
|
}
|
58
|
55
|
|
59
|
56
|
public boolean findHoratio() {
|