|
@@ -1,6 +1,9 @@
|
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;
|
|
6
|
+
|
4
|
7
|
|
5
|
8
|
/**
|
6
|
9
|
* Created by thook on 10/7/15.
|
|
@@ -8,6 +11,7 @@ import java.util.Scanner;
|
8
|
11
|
public class HamletParser {
|
9
|
12
|
|
10
|
13
|
private String hamletData;
|
|
14
|
+ String patt = "\bHamlet\b";
|
11
|
15
|
|
12
|
16
|
public HamletParser(){
|
13
|
17
|
this.hamletData = loadFile();
|
|
@@ -36,4 +40,32 @@ public class HamletParser {
|
36
|
40
|
return hamletData;
|
37
|
41
|
}
|
38
|
42
|
|
|
43
|
+ public void changeHamletToLeon(){
|
|
44
|
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
|
|
45
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
46
|
+ hamletData = matcher.replaceAll("Leon");
|
|
47
|
+
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ public void changeHoratioToTariq(){
|
|
51
|
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
|
|
52
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
53
|
+ hamletData = matcher.replaceAll("Tariq");
|
|
54
|
+
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+ public boolean findHamlet() {
|
|
59
|
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
|
|
60
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
61
|
+ return matcher.find();
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ public boolean findHoratio() {
|
|
65
|
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
|
|
66
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
67
|
+ return matcher.find();
|
|
68
|
+ }
|
39
|
69
|
}
|
|
70
|
+
|
|
71
|
+
|