Let's say I have the following String S = "00-44 48 5555 8361"
entry and I need to return this 3-by-3 split string separated by "-" as follows:
Output: 004-448-555-583-61
The number of characters may vary. Below the following scope:
public class Solution{
public static String solution(String S){
}
}
public static void main(String[] args) {
String S = "00-44 48 5555 8361";
System.out.print(solution(S));
}
}
In an effective way, how to solve this in Java 8?