Solved: symbol validation check question |
Hi,
I have this code below which lets me validate folder names. PHP Code: $is_correct_foldername = strpbrk($this->input->post('folder'), "\\/?%*:@#${}|\"<>"); How can I make sure folder name contains no spaces. As you can see in my strpbrk I have symbols that are not allow. Thanks
Found solution did like
PHP Code: $is_correct_foldername = strpbrk($this->input->post('folder'), "\\/?%*:@#$|\"<>" . "{}" . " ");
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
Personally I would match characters I want instead of those I don't want. Right now you can use chines letters in your folder name, are you allowed to do so?
PHP Code: $re = '/\W/'; // \W matches any non-word character (equal to [^a-zA-Z0-9_]) This will give you false on every character except: a-z A-Z 0-9 _
(04-05-2018, 11:17 AM)jreklund Wrote: Personally I would match characters I want instead of those I don't want. Right now you can use chines letters in your folder name, are you allowed to do so? And spaces?
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |