cgm225 Posted May 25, 2008 Share Posted May 25, 2008 What is the regular expression for just numbers? I have this for numbers and letters: $regex = '/[^-_A-z0-9]++/'; Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 25, 2008 Share Posted May 25, 2008 remove the letters? $regex = '/[^0-9]++/'; Quote Link to comment Share on other sites More sharing options...
Orio Posted May 26, 2008 Share Posted May 26, 2008 That will match "everything BUT numbers". Also you need only one "+" (or "*", depends on what you're looking for). Anyway, it should look like this: <?php if(preg_match("/^[0-9]+$/", $num_input)) echo "Valid input"; ?> Orio. Quote Link to comment Share on other sites More sharing options...
teng84 Posted May 27, 2008 Share Posted May 27, 2008 you you only need to validate numbers simply use ctype_digit or is_numeric Quote Link to comment 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.