Welcome to WebmasterWorld Guest from 54.159.246.164

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

preg match help

   
6:11 pm on Jul 4, 2007 (gmt 0)

5+ Year Member



Can anyone pls help me write the regex for validating $id using ereg or preg_match?

$id will consist of any number, followed by a ; followed by a 1 or 2. For example:

1283;1
232;1
1932034;2
0018;2
5;1

etc.

Thanks in advanced!

6:47 pm on Jul 4, 2007 (gmt 0)

5+ Year Member



if (preg_match("^[0-9]+;[12]{1}$", $id))
{
echo "A match was found.";
}
else
{
echo "A match was not found.";
}

Milan