Nick Satinover 6 anos atrás
pai
commit
6be245d654
1 arquivos alterados com 10 adições e 3 exclusões
  1. 10
    3
      src/main/java/HamletParser.java

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

@@ -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
 }