Nick Satinover hace 6 años
padre
commit
6be245d654
Se han modificado 1 ficheros con 10 adiciones y 3 borrados
  1. 10
    3
      src/main/java/HamletParser.java

+ 10
- 3
src/main/java/HamletParser.java Ver fichero

@@ -60,9 +60,16 @@ public class HamletParser {
60 60
 
61 61
     public String replaceHamletAndHoratio(String input) {
62 62
 
63
-        String noHamlet = input.replaceAll("(?i)hamlet", "Leon");
64
-        String noHoratioOrHamlet = noHamlet.replaceAll("(?i)horatio", "Tarik");
65
-        return noHoratioOrHamlet;
63
+        Pattern pattern = Pattern.compile("(?i)hamlet");
64
+        Matcher matcher = pattern.matcher(input);
65
+
66
+        String replaceHamlet = matcher.replaceAll("Leon");
67
+
68
+        Pattern pattern1 = Pattern.compile("(?i)horatio");
69
+        Matcher matcher1 = pattern1.matcher(replaceHamlet);
70
+
71
+        String replaceHoratio = matcher1.replaceAll("Tarik");
72
+        return replaceHoratio;
66 73
     }
67 74
 
68 75
 }