|
@@ -1,6 +1,8 @@
|
1
|
1
|
import java.io.File;
|
2
|
2
|
import java.io.IOException;
|
3
|
3
|
import java.util.Scanner;
|
|
4
|
+import java.util.regex.Matcher;
|
|
5
|
+import java.util.regex.Pattern;
|
4
|
6
|
|
5
|
7
|
/**
|
6
|
8
|
* Created by thook on 10/7/15.
|
|
@@ -36,4 +38,29 @@ public class HamletParser {
|
36
|
38
|
return hamletData;
|
37
|
39
|
}
|
38
|
40
|
|
|
41
|
+ public void changeHamletToLeon() {
|
|
42
|
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
|
|
43
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
44
|
+ hamletData = matcher.replaceAll("Leon");
|
|
45
|
+
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ public void changeHoratioToTariq() {
|
|
49
|
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
|
|
50
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
51
|
+ hamletData = matcher.replaceAll("Tariq");
|
|
52
|
+
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ public boolean findHoratio() {
|
|
56
|
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
|
|
57
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
58
|
+ return matcher.find();
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ public boolean findHamlet() {
|
|
62
|
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
|
|
63
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
64
|
+ return matcher.find();
|
|
65
|
+ }
|
39
|
66
|
}
|