我想用阿拉伯數字替換阿拉伯數字字符,因爲我用下面的方法替換了阿拉伯字符的任何實例,但唯一的問題是我無法將阿拉伯文逗號轉換爲英文逗號使用特定的方法。用字符串中的英文替換阿拉伯語逗號
public String convertNumbersToEnglish(String str) {
if(str!=null && !str.equals("")){
String answer = str;
answer = answer.replace("١", "1");
answer = answer.replace("٢", "2");
answer = answer.replace("٣", "3");
answer = answer.replace("٤", "4");
answer = answer.replace("٥", "5");
answer = answer.replace("٦", "6");
answer = answer.replace("٧", "7");
answer = answer.replace("٨", "8");
answer = answer.replace("٩", "9");
answer = answer.replace("٠", "0");
answer = answer.replace("،",",");
return answer;
}else{
return "";
}
}
有你有在一個阿拉伯語逗號,一個失敗的字符串的一個例子通過代碼來代替? –
是的,我確實嘗試過,但逗號是倒置的 –
然後,您需要爲_that_類型的逗號包含'replace'命令。 –