I'm trying to create a java app that takes a chemical formula like "CH3COOH" and returns some sort of collection full of their symbols.
CH3COOH would return [C,H,H,H,C,O,O,H]
I already have something that is kinda working, but it's very complicated and uses a lot of code with a lot of nested if-else structures and loops.
Is there a way I can do this by using some kind of regular expression with String.split or maybe in some other brilliant simple code?