ToonMariner Posted August 27, 2009 Share Posted August 27, 2009 Need regex that allows digits '-' and ' ' but must have at least 1 digit... (?!^[0-9]*$)^([0-9\ -]+)$ is where I'm at now but its just not working... [0-9]+ and [\ \-]? but NOTHING else cheers peeps Quote Link to comment https://forums.phpfreaks.com/topic/172052-solved-brain-not-working/ Share on other sites More sharing options...
nrg_alpha Posted August 27, 2009 Share Posted August 27, 2009 Need regex that allows digits '-' and ' ' but must have at least 1 digit... Perhaps something along the lines of: $str = '- -6'; echo (preg_match('#^[0-9 -]*[0-9][0-9 -]*$#', $str))? "$str is in the correct format!" : "$str is NOT in the correct format!"; ? Quote Link to comment https://forums.phpfreaks.com/topic/172052-solved-brain-not-working/#findComment-907187 Share on other sites More sharing options...
ToonMariner Posted August 27, 2009 Author Share Posted August 27, 2009 thank you - could not see woods for trees!!! Quote Link to comment https://forums.phpfreaks.com/topic/172052-solved-brain-not-working/#findComment-907202 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.