Skip to content

Commit 7882213

Browse files
committed
Oops; use replaceAll, not replace - stop trying to optimize for ^
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@634917 13f79535-47bb-0310-9956-ffa450edef68
1 parent de10106 commit 7882213

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/java/org/apache/commons/codec/language/Caverphone.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ public String caverphone(String txt) {
6262
txt = txt.replaceAll("[^a-z]", "");
6363

6464
// 2.5. Remove final e
65-
txt = txt.replace("e$", ""); // 2.0 only
65+
txt = txt.replaceAll("e$", ""); // 2.0 only
6666

6767
// 3. Handle various start options
68-
txt = txt.replace("^cough", "cou2f");
69-
txt = txt.replace("^rough", "rou2f");
70-
txt = txt.replace("^tough", "tou2f");
71-
txt = txt.replace("^enough", "enou2f"); // 2.0 only
72-
txt = txt.replace("^trough", "trou2f"); // 2.0 only - note the spec says ^enough here again, c+p error I assume
73-
txt = txt.replace("^gn", "2n");
74-
txt = txt.replace("^mb", "m2");
68+
txt = txt.replaceAll("^cough", "cou2f");
69+
txt = txt.replaceAll("^rough", "rou2f");
70+
txt = txt.replaceAll("^tough", "tou2f");
71+
txt = txt.replaceAll("^enough", "enou2f"); // 2.0 only
72+
txt = txt.replaceAll("^trough", "trou2f"); // 2.0 only - note the spec says ^enough here again, c+p error I assume
73+
txt = txt.replaceAll("^gn", "2n");
74+
txt = txt.replaceAll("^mb", "m2");
7575

7676
// 4. Handle replacements
7777
txt = txt.replaceAll("cq", "2q");
@@ -91,7 +91,7 @@ public String caverphone(String txt) {
9191
txt = txt.replaceAll("b", "p");
9292
txt = txt.replaceAll("sh", "s2");
9393
txt = txt.replaceAll("z", "s");
94-
txt = txt.replace("^[aeiou]", "A");
94+
txt = txt.replaceAll("^[aeiou]", "A");
9595
txt = txt.replaceAll("[aeiou]", "3");
9696
txt = txt.replaceAll("j", "y"); // 2.0 only
9797
txt = txt.replaceAll("^y3", "Y3"); // 2.0 only
@@ -113,7 +113,7 @@ public String caverphone(String txt) {
113113
txt = txt.replaceAll("w$", "3"); // 2.0 only
114114
//txt = txt.replaceAll("why", "Why"); // 1.0 only
115115
txt = txt.replaceAll("w", "2");
116-
txt = txt.replace("^h", "A");
116+
txt = txt.replaceAll("^h", "A");
117117
txt = txt.replaceAll("h", "2");
118118
txt = txt.replaceAll("r3", "R3");
119119
txt = txt.replaceAll("r$", "3"); // 2.0 only

0 commit comments

Comments
 (0)