Here is my regexp to accept only Yes or No (not case sensitive). Is there a better way to do it? Thanks
preg_match('/^(?:Yes\b|YES\b|yes\b|No\b|NO\b|no\b)/',$input)
You may use i
modifier.
preg_match('~^(?:Yes|no)\b~i', $input);
Add end of the line anchor $
if necessary.
preg_match('~^(?:Yes|no)$~i', $input);