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
Post a Comment