robos99 Posted June 11, 2006 Share Posted June 11, 2006 I've got the following regular expression pattern: "^[0-9]+$"to check if a string supplied is a number or not, but i keep getting warnings from php: Warning: preg_match(): No ending delimiterI'm kinda confused because isn't the $ the ending delimiter? Maybe I'm missing something. Quote Link to comment https://forums.phpfreaks.com/topic/11745-regex-syntax-problem/ Share on other sites More sharing options...
poirot Posted June 12, 2006 Share Posted June 12, 2006 The regex should be:"/^[0-9]+$/" or "/^\d+$/"You can also use typcasting and convert the value to a number, using (float) $var, (int) var, settype(), and so on[code]<?phpecho $_GET['d'] . '<br />';echo (preg_match("/^\d+$/", $_GET['d'])) ? 'true' : 'false';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11745-regex-syntax-problem/#findComment-44492 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.