私はtesseract ocrから得た電子メールを編集しています。String.replaceAll()が機能していません
は、ここに私のコードです:
if (email != null) {
email = email.replaceAll(" ", "");
email = email.replaceAll("caneer", "career");
email = email.replaceAll("canaer", "career");
email = email.replaceAll("canear", "career");
email = email.replaceAll("caraer", "career");
email = email.replaceAll("carear", "career");
email = email.replace("|", "l");
email = email.replaceAll("}", "j");
email = email.replaceAll("j3b", "job");
email = email.replaceAll("gmaii.com", "gmail.com");
email = email.replaceAll("hotmaii.com", "hotmail.com");
email = email.replaceAll(".c0m", ".com");
email = email.replaceAll(".coin", ".com");
email = email.replaceAll("consuit", "consult");
}
return email;
しかし、出力が正しくありません。
入力:
[email protected] mai|.com
出力:
[email protected]|l.lclolml
しかし、私はすべての交換後の新しい文字列に結果を割り当てられたときに、それが正常に動作します。同じ文字列内の連続した代入が機能しないのはなぜですか?
によって単語
career
のisspellings私は/で(および5行目にタイプミスを修正する)ことをコピー&ペースト、それは正しい結果であると思われるものになります。 [email protected] " – RenreplaceAllの代わりにString.replaceを使用することを検討してください。私がreplaceAllがやるべきと思っているとまったく同じことをします。 – Buhb
私の目はそのようなコードを見ることで痛いです。 –