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 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!"; ? 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!!! Link to comment https://forums.phpfreaks.com/topic/172052-solved-brain-not-working/#findComment-907202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.