Browse Source

replace to replaceAll

Kajetan Johannes Hammerle 3 years ago
parent
commit
16a9aaa860
1 changed files with 26 additions and 26 deletions
  1. 26 26
      web/js/endlerbrecer.js

+ 26 - 26
web/js/endlerbrecer.js

@@ -4,18 +4,18 @@ function translateText() {
     text = text + " ";
 
     text = text.toLowerCase();
-    text = text.replace("ü", "u");
-    text = text.replace("ö", "o");
-    text = text.replace("ä", "e");
-    text = text.replace("ß", "s");
-    text = text.replace("sch", "s");
-    text = text.replace("ch", "c");
-    text = text.replace("au", "u");
-    text = text.replace("ei", "EI");
-    text = text.replace("eu", "EU");
-    text = text.replace("sp", "p");
-    text = text.replace("st", "t");
-    text = text.replace("pf", "f");
+    text = text.replaceAll("ü", "u");
+    text = text.replaceAll("ö", "o");
+    text = text.replaceAll("ä", "e");
+    text = text.replaceAll("ß", "s");
+    text = text.replaceAll("sch", "s");
+    text = text.replaceAll("ch", "c");
+    text = text.replaceAll("au", "u");
+    text = text.replaceAll("ei", "EI");
+    text = text.replaceAll("eu", "EU");
+    text = text.replaceAll("sp", "p");
+    text = text.replaceAll("st", "t");
+    text = text.replaceAll("pf", "f");
 
     let permute = "";
     for (let i = 0; i < text.length; i++) {
@@ -47,25 +47,25 @@ function translateText() {
         "y", "z"];
 
     for (let i = 0; i < letters.length; i++) {
-        text = text.replace(letters[i] + letters[i], letters[i]);
+        text = text.replaceAll(letters[i] + letters[i], letters[i]);
     }
 
-    text = text.replace("r ", "RE ");
-    text = text.replace("e ", "ER ");
-    text = text.replace("a ", "AR ");
-    text = text.replace("d ", "DE ");
-    text = text.replace("l ", "LE ");
-    text = text.replace("m ", "MER ");
-    text = text.replace("n ", "NE ");
-    text = text.replace("s ", "SA ");
+    text = text.replaceAll("r ", "RE ");
+    text = text.replaceAll("e ", "ER ");
+    text = text.replaceAll("a ", "AR ");
+    text = text.replaceAll("d ", "DE ");
+    text = text.replaceAll("l ", "LE ");
+    text = text.replaceAll("m ", "MER ");
+    text = text.replaceAll("n ", "NE ");
+    text = text.replaceAll("s ", "SA ");
 
-    text = text.replace("ie", "IA");
-    text = text.replace("h", "");
+    text = text.replaceAll("ie", "IA");
+    text = text.replaceAll("h", "");
 
-    text = text.replace("EI", "a");
-    text = text.replace("EU", "o");
+    text = text.replaceAll("EI", "a");
+    text = text.replaceAll("EU", "o");
 
     text = text.toLowerCase();
 
     document.getElementById("output").innerHTML = text;
-}
+}