From: "George Lunsford" <george.lunsford / gmail.com> > > Unfortunately this doesn't seem to work > properly as a (nonsense) word like "presenti" should be periodic according > to my list of elements, [p][re][se][n][ti]. Now, I can duplicate this > behavior with the regex coach oddly enough. Hi, welcome to Ruby! Not sure if this helps, but here's what I get: elems = "He|Li|Be|C|O|Ne|Na|Mg|Al|Si|S|Cl|Ar|Ca|Sc|Ti|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|\ As|Se|Br|Kr|Rb|Sr|Zr|Nb|Mo|Tc|Ru|Rh|Pd|Ag|Cd|In|Sn|Sb|Te|Xe|Cs|Ba|Hf|Ta|Re|Os|Ir|\ Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Rf|Db|Sg|Bh|Hs|Mt|Uun|Uuu|Uub|Uuq|Uuh|Uuo|Ds|La|\ Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Lu|Ac|Th|Pa|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No|\ Lr|H|B|N|F|P|V|Y|I|W|Uaal" # using \b to anchor at word boundaries "presenti" =~ /\b(?:#{elems})+\b/i 0 # matches whole word # using scan to see which elements are being matched # (note that this approach would inappropriately skip # over letters at the beginning of the word that weren't # elements... but any match that it does find will # be contiguous elements from that point to the end of # the word... however one could perform the above check # first to make sure the whole word matched, and then # use the scan to obtain the individual elements) "presenti".scan(/(?:#{elems})(?=(?:#{elems})*\b)/i) ["p", "re", "se", "n", "ti"] "prese".scan(/(?:#{elems})(?=(?:#{elems})*\b)/i) ["p", "re", "se"] Regards, Bill