Created
August 6, 2014 18:30
-
-
Save pixshatterer/340c4140eed6f39925c1 to your computer and use it in GitHub Desktop.
EXAMINE THIS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parseMolecule=function x(f,r){ | |
| for(r=1;r;) | |
| r=0,f=f.replace(/\W(([A-Z][a-z]*\d*)*)[)\]}](\d*)/g,function(m,g,_,c){ | |
| _='';for(r in m=x(g))_+=r+m[r]*(c||1);return _ | |
| }) | |
| for(r={},m=/(\w[a-z]*)(\d*)/g;a=m.exec(f);r[c]+=+a[2]||1) | |
| r[c=a[1]]|=0 | |
| return r | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment