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 Quote Link to comment Share on other sites More sharing options...
.josh Posted April 28, 2011 Share Posted April 28, 2011 "/^[-a-z0-9_ ]+$/i" Quote Link to comment 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 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.