我想在长度为 35 时分割一个字符串,例如“仅卢比 241 和 68”,我想将该字符串分割为 2。我尝试使用此代码来分割该字符串。
String text = "Rupees Two Hundred Forty One and Sixty Eight only";
List<String> parts = new ArrayList<>();
int length = text.length();
for (int i = 0; i < length; i += 35) {
parts.add(text.substring(i, Math.min(length, i + size)));
但输出是这样的。
[Rupees Two Hundred Forty One and Si, xty Eight only]
但我想像这样分割字符串。
[Rupees Two Hundred Forty One and, Sixty Eight only]
分割字符串时没有切词。该字符串每次都会根据账单金额而变化。
胡子哥哥
aluckdog
慕神8447489
喵喵时光机
相关分类