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 Link to comment https://forums.phpfreaks.com/topic/91661-allow-a-space/ 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) Link to comment https://forums.phpfreaks.com/topic/91661-allow-a-space/#findComment-469446 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. Link to comment https://forums.phpfreaks.com/topic/91661-allow-a-space/#findComment-469638 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 Link to comment https://forums.phpfreaks.com/topic/91661-allow-a-space/#findComment-471092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.