String split
I hv a string String str = "111233333445556"I want to use split() method in such a way that it return strings containing same characters only, like"111""2""33333""44""555""6"
public class Test
{
public static void main(String... args)
{
String str = "111233333445556";
String[] parts = str.split("(?<=(.))(?!\\1)");
System.out.println(Arrays.toString(parts));
}
}
> You did that to spur uncle_alice on, right?Well I, for one, definitely wouldn't use a regex to cure cancer.