php_dave Posted February 18, 2008 Share Posted February 18, 2008 All, Sorry but I couldnt find anything under search... I have thiis statement preg_match("/^[-0-9A-Z_\[\]]+$/i", $attachname) Which is checking a filename for attachment into a forum - it is not allowing for any spaces - what do i need to change/add to allow for spaces in the filename? Thanks in advance Dave Quote Link to comment Share on other sites More sharing options...
doug007 Posted February 18, 2008 Share Posted February 18, 2008 All, Sorry but I couldnt find anything under search... I have thiis statement preg_match("/^[-0-9A-Z_\[\]]+$/i", $attachname) Which is checking a filename for attachment into a forum - it is not allowing for any spaces - what do i need to change/add to allow for spaces in the filename? Thanks in advance Dave try this. not sure if it will work though. preg_match("/^[-0-9A-Z_\[\]]*?\s+$/i", $attachname) Quote Link to comment Share on other sites More sharing options...
effigy Posted February 18, 2008 Share Posted February 18, 2008 /\A[-\w\x20\[\]]+\z/i You'll want to trim the string beforehand so a string of nothing but spaces will not be accepted. Quote Link to comment Share on other sites More sharing options...
php_dave Posted February 19, 2008 Author Share Posted February 19, 2008 Hey guys, Thanks for the code - works a treat! Cheers Dave 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.