Regex expression to mach one of many strings in php -


i totally new regex , want match if value 1 of following

cs,ch,es,ee,it,me

till have tried

if (preg_match("/^[cs|ch|es|ee|it|me]{2}$/",$val))     echo "true"; else     echo "false"; 

its working fine true cases returns true reverse of them sc,hc etc. helpful if refer source/books learn php.

remove character class [] regex , wrap them using (). remove {2} not necessary anymore.

if (preg_match("/^(cs|ch|es|ee|it|me)$/",$val)) 

and you.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -