homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
preg match help
FiRe




msg:3386269
 6:11 pm on Jul 4, 2007 (gmt 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!

 

milanmk




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

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

Milan

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved