Welcome to WebmasterWorld Guest from 54.167.40.25

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

preg match help

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

Full Member

10+ Year Member

joined:Aug 9, 2005
posts:240
votes: 0


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 July 4, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Jan 4, 2006
posts:307
votes: 0


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

Milan