|
@@ -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,28 @@ public class HamletParser {
|
36
|
38
|
return hamletData;
|
37
|
39
|
}
|
38
|
40
|
|
|
41
|
+ public boolean findHoratio() {
|
|
42
|
+ Pattern pattern = Pattern.compile(("Horatio"));
|
|
43
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
44
|
+ return matcher.find();
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ public void changeHorationToTariq() {
|
|
48
|
+ Pattern pattern = Pattern.compile(("Horatio"));
|
|
49
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
50
|
+ hamletData = matcher.replaceAll("Tariq");
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ public boolean findHamlet() {
|
|
54
|
+ Pattern pattern = Pattern.compile(("Hamlet"));
|
|
55
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
56
|
+ return matcher.find();
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ public void changeHamlettToLeon() {
|
|
60
|
+ Pattern pattern = Pattern.compile("Hamlet");
|
|
61
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
62
|
+ hamletData = matcher.replaceAll("Leon");
|
|
63
|
+ }
|
|
64
|
+
|
39
|
65
|
}
|