php regex form questions
Is it possible to just use this code alone to do two different regex matches?
One reg-ex match for X digits and the other for a given string "CAT" only, or do I need to create two different forms, one for each: X digits and one for the string "CAT"?
Furthermore is there a better php method for this or I am hea开发者_运维问答ded in the right direction?
Thank you in advance.
<form action ="callself.php" method = "post">
Enter a numeric value:
<br/>
<input type = "text" name = "number"/>
<br /><br />
<input type = "submit"/>
<br /><br />
</form>
I am a newb(still in the process of learning, thank you in advance for not flaming)
If you just want to check if the field contanins either CAT
or a sequence of digit, you can use this check:
if (preg_match('/^(?:CAT|\d+)$/', $field))
if you need to act differently in the two cases, explain better.
精彩评论