Seth vor 6 Jahren
Ursprung
Commit
617228466e
2 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen
  1. 4
    4
      src/main/java/HamletParser.java
  2. 1
    0
      src/test/java/HamletParserTest.java

+ 4
- 4
src/main/java/HamletParser.java Datei anzeigen

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

+ 1
- 0
src/test/java/HamletParserTest.java Datei anzeigen

22
 
22
 
23
         Assert.assertFalse(actual);
23
         Assert.assertFalse(actual);
24
     }
24
     }
25
+    
25
 
26
 
26
     @Test
27
     @Test
27
     public void testChangeHoratioToTariq() {
28
     public void testChangeHoratioToTariq() {