[Solved] How to add spaces in between numbers contained inside a string? [closed]

[ad_1]

Try this

String str = "DOC_87654321 -ABC76543";
StringBuilder sb = new StringBuilder();

for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (Character.isDigit(c)) {
        sb.append(c + " ");
    } else {
        sb.append(c);
    }
}
Log.e("DATA",sb.toString());

12

[ad_2]

solved How to add spaces in between numbers contained inside a string? [closed]