Given the rather limited and specific set of codes you are checking, I would suggest using
in_array($inputvalue,array('C','D','F','H','I','E1','E2','CR'));
not a regular expression - it will work faster than a regular expression, and will be easier to describe later and change later.
source share