I want to split this string "AHHHAAAAARTFUHLAAAAAHV" using a delimiter "AAAA" and save it to an array including the delimiter. (desired output: [AHHHA, AAAA, RTFUHLA, AAAA ,HV]). I have the following codes below but the output is not the same to my desired output.
String y = "AHHHAAAAARTFUHLAAAAAHV";
System.out.println(Arrays.toString(y.split("((?<=AAAA)|(?=AAAA))")));
OUPUT: [AHHH, A, AAA, A, RTFUHL, A, AAA, A, HV]
Arrays.toString(y.split("(?=AAAA[^A]|(?<=AAAA(?=[^A])))"))?AHHHAAAAAcould be split into eitherAHHH, AAAA, AorAHHHA, AAAA. What is your expected outcome forAAAAAAAAA(9As)?AAAAA, AAAA, orA, AAAA, AAAA, or ...?