Input >
user_input = 123456789
format = "xx-xxx-x-xx-x"
Output >
12-345-6-78-9
Or
Input >
user_input = 123456
format = "x-xx-x-x-x"
Output >
1-23-4-5-6
I do everything i can and try to another language(python,js) but it not work.
it have problem after else statement
String a = "123456";
String b = "xxx-xx-x";
char[] c_arr = b.toCharArray();
for (int i = 0; i < b.length(); i++) {
if(c_arr[i] != '-'){
c_arr[i] = a.charAt(i);
} else {
c_arr[i+1] = a.charAt(i);
}
System.out.println(c_arr);
}