I have a simple string with Chinese characters in my Android application and want to replace one character with another...
As a sample, I have this code:
String old_string = "啤酒";
String new_string = old_string.replaceAll("一", "啤");
Log.d(TAG, "transformed "+old_string+" into "+new_string);
This will not do anything:
transformed 啤酒 into 啤酒
Also tried with replace
instead of replaceAll
without any luck.
您需要在replaceAll调用中切换参数的顺序:
replaceAll("啤", "--")
尝试交换周围的值:
String new_string = old_string.replaceAll("啤", "一");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.