OBJECTIVE
Filter out the SMILES strings if any alphabetical letter (atoms) in the string, insensitive to capitalization, does not come from the following list of elements H, B, C, N, O, F, Al, Si, P, S, Cl, this is a truncated list. In total, there are 38 elements.
BACKGROUND
I have a database containing SMILES strings:
The simplified molecular-input line-entry system (SMILES) is a specification in the form of a line notation for describing the structure of chemical species using short ASCII strings.
(More info Wikipedia link)
SMILES example:
OC[C@H]1O[C@H]([C@H](O)[C@@H]1O)n1cnc2c(NC3CCCC3)ncnc12
The purpose of this was to get rid of rare elements and organometallics from the database.