in reply to Re: Recursive capture of a variable number of elements using regexp
in thread Recursive capture of a variable number of elements using regexp

If I remember my chemistry correctly, and I probably don't, but can't the same element appear more than once in a formula, and if so then using a hash would elide some of the elements?

  • Comment on Re^2: Recursive capture of a variable number of elements using regexp

Replies are listed 'Best First'.
Re^3: Recursive capture of a variable number of elements using regexp
by linuxer (Curate) on Apr 09, 2009 at 18:47 UTC

    As long as the formulas are sum formulas, there should be no problem, as each element should be summed up and shouldn't appear again in the same formula. So it should be fine with C2H6O.

    If the formula tries to represent some kind of molecular structure, you may be right: CH3CH2OH

    (Both formulas represent ethanol).

Re^3: Recursive capture of a variable number of elements using regexp
by kennethk (Abbot) on Apr 09, 2009 at 19:23 UTC
    What linuxer said. Given the sample data, I was assuming the OP was just interested in Hill Order formulas. Technically speaking though, you are correct, and I will admonish appropriately.