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
하지만 모든 교체 후 새 문자열로 결과를 할당 할 때, 그것은 잘 작동합니다. 동일한 String에서 연속 할당이 작동하지 않는 이유는 무엇입니까?
내가 복사/다음
regex
에 의해 단어career
의 isspellings, 그것은 올바른 결과로 보이는 결과에 (라인 5에 오타 수정) 것을 붙여 넣습니다. [email protected] "을 클릭하십시오. – RenreplaceAll 대신 String.replace를 사용해보십시오. replaceAll이 기대하는 바를 정확히 믿습니다. – Buhb
내 눈은 그런 식의 코드를 보면서 아플 것입니다. –