Seth 6 years ago
parent
commit
617228466e
2 changed files with 5 additions and 4 deletions
  1. 4
    4
      src/main/java/HamletParser.java
  2. 1
    0
      src/test/java/HamletParserTest.java

+ 4
- 4
src/main/java/HamletParser.java View File

@@ -39,25 +39,25 @@ public class HamletParser {
39 39
     }
40 40
 
41 41
     public boolean findHoratio() {
42
-        Pattern pattern = Pattern.compile(("Horatio"));
42
+        Pattern pattern = Pattern.compile(("[Hh][Oo][Rr][Aa][Tt][Ii][Oo]"));
43 43
         Matcher matcher = pattern.matcher(hamletData);
44 44
         return matcher.find();
45 45
     }
46 46
 
47 47
     public void changeHorationToTariq() {
48
-        Pattern pattern = Pattern.compile(("Horatio"));
48
+        Pattern pattern = Pattern.compile(("[Hh][Oo][Rr][Aa][Tt][Ii][Oo]"));
49 49
         Matcher matcher = pattern.matcher(hamletData);
50 50
         hamletData = matcher.replaceAll("Tariq");
51 51
     }
52 52
 
53 53
     public boolean findHamlet() {
54
-        Pattern pattern = Pattern.compile(("Hamlet"));
54
+        Pattern pattern = Pattern.compile(("[Hh][Aa][Mm][Ll][Ee][Tt]"));
55 55
         Matcher matcher = pattern.matcher(hamletData);
56 56
         return matcher.find();
57 57
     }
58 58
 
59 59
     public void changeHamlettToLeon() {
60
-        Pattern pattern = Pattern.compile("Hamlet");
60
+        Pattern pattern = Pattern.compile("[Hh][Aa][Mm][Ll][Ee][Tt]");
61 61
         Matcher matcher = pattern.matcher(hamletData);
62 62
         hamletData = matcher.replaceAll("Leon");
63 63
     }

+ 1
- 0
src/test/java/HamletParserTest.java View File

@@ -22,6 +22,7 @@ public class HamletParserTest {
22 22
 
23 23
         Assert.assertFalse(actual);
24 24
     }
25
+    
25 26
 
26 27
     @Test
27 28
     public void testChangeHoratioToTariq() {