I need a way to separate a chemical formula into its components. The result should look like this:
Ag3PO4 -> [
This should just about work:
/(\(?)([A-Z])([a-z]*)([0-9]*)(\))?([0-9]*)/g
Play around with it here: http://refiddle.com/