I have a string
"Red apple, blue banana, orange".
How could I split it by ", " first then add "_" between two words (such as Red_apple but not orange) and capitalize all letters. I read a few posts and found a solution but it only has the split part and how could I also add "_" and capitalize all letters? :
Pattern pattern = Pattern.compile(", ");
List<Fruit> f = pattern.splitAsStream(fruitString)
.map(Fruit::valueOf)
.collect(Collectors.toList());
Fruit is a enum object. So basically if I am able to convert a string to a certain format and I am able get a Enum object based on a Enum name.