I have one string like below
A:82% X 18% Y B:100% X C:82% X 18% Y AB:82% X 18% Y
Want to convert above string into below format (Required Format)
#A:82% X,18% Y #B:100% X #C:82% X,18% Y #AB:82% X,18% Y
I'm able to achieve this
#A:82% X 18% Y #B:100% X #C:82% X 18% Y #AB:82% X 18% Y
using this code
String inp = "A:82% X 18% Y B:100% X C:82% X 18% Y AB:82% X 18% Y";
String regex = "(\\b[A-Za-z]{1,}\\:\\b)";
System.out.println(inp.replaceAll(regex, "#$1"));
But am not able to find a way where I could place commas the way I want mentioned in required format.
Is there any way I could select only words except "#word:", "Number%" and "spaces", so that in resultant I could select only Xs and Ys (X and Y is just an example, other word are also possible). Because once am able to select those words then I can replace them with "$1,"
Thanks