rbrown Posted April 28, 2011 Share Posted April 28, 2011 I'm trying to us a preg_match where if the string contains spaces, dashes, underscores, A-z, a-z, 0-9 it will let it pass. If it has any other character it won't. I got the it to work with the underscore, A-z, a-z, 0-9 but trying to add the dash and space I'm just not getting it right. And I'm running out of hair... example file names: GittlingerBaier_AnnMarie_19707_04_06_11.pdf --- this works Gittlinger-Baier_Ann Marie_19707_04_06_11.pdf --- want this to pass Gittlinger,Baier_Ann%Marie_19707_04_06_11.pdf --- want this to fail This below works. But it doesn't allow spaces or dashes $file_name_exploded_extension = explode('.',$file['name']); if (preg_match("/^[a-z0-9_]+$/i", $file_name_exploded_extension['0']) ) { Thanks, Bob Link to comment https://forums.phpfreaks.com/topic/234929-preg_match/ Share on other sites More sharing options...
.josh Posted April 28, 2011 Share Posted April 28, 2011 "/^[-a-z0-9_ ]+$/i" Link to comment https://forums.phpfreaks.com/topic/234929-preg_match/#findComment-1207341 Share on other sites More sharing options...
rbrown Posted April 28, 2011 Author Share Posted April 28, 2011 Thanks Crayon... As always... you rule... Bob Link to comment https://forums.phpfreaks.com/topic/234929-preg_match/#findComment-1207343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.