Destramic Posted May 31, 2010 Share Posted May 31, 2010 hey guys im need to be able to see if a string contains a certian character :1 or :2 etc...it will be a colon then a number i know it needs to be done by using eregi but im not sure on how to do it if anyone can help please...thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/203423-php-eregi/ Share on other sites More sharing options...
ZachMEdwards Posted June 1, 2010 Share Posted June 1, 2010 $pattern = '/:\d/'; //for a single digit $pattern = '/:\d{1,5}/'; //single digit, between 1 and 5 times $pattern = '/:\d+/'; //single digit, between one and unlimited times if(ereg($pattern, $str)) { //it matched! } Edit: actually, ereg is deprecated: if(preg_match($pattern, $str)) { //it matched! } Quote Link to comment https://forums.phpfreaks.com/topic/203423-php-eregi/#findComment-1065951 Share on other sites More sharing options...
Destramic Posted June 2, 2010 Author Share Posted June 2, 2010 thanks you for your reply and help Quote Link to comment https://forums.phpfreaks.com/topic/203423-php-eregi/#findComment-1066876 Share on other sites More sharing options...
GoneNowBye Posted June 7, 2010 Share Posted June 7, 2010 sorry to bump, but on that note, what was ereg? (i'm learning - ish - preg so it does predate me) Quote Link to comment https://forums.phpfreaks.com/topic/203423-php-eregi/#findComment-1069125 Share on other sites More sharing options...
cags Posted June 7, 2010 Share Posted June 7, 2010 It was one of a group of functions that used the POSIX style of Regular Expressions instead of the PCRE style. There is a lot of crossover between the two, but with subtle differences. There is brief explanation of some of the differences in the PCRE section of the manual (which is also linked to from the ereg page). Quote Link to comment https://forums.phpfreaks.com/topic/203423-php-eregi/#findComment-1069142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.