tags:

views:

30

answers:

1

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 headed 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)

+2  A: 

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.

kemp
I guess, using the above method, I might as well just remove the second form I had created, thank you.
Newb