I want to validate a file name
Name of file or folder should not contain \ / ? % * : | " < > .
Could you please suggest me the regex expression to use in preg_match()?
Thanks.
I want to validate a file name
Name of file or folder should not contain \ / ? % * : | " < > .
Could you please suggest me the regex expression to use in preg_match()?
Thanks.
 
    
    It would be more efficient to use the strpbrk() function.
if (strpbrk($filename, "\\/?%*:|\"<>") === FALSE) {
  /* $filename is legal; doesn't contain illegal character. */
}
else {
  /* $filename contains at least one illegal character. */
}
 
    
    new RegExp('^[a-zA-Zа-яА-Я0-9_!]+$')
http://regexpal.com/ try this site
 
    
    new RegExp('^[^\\\\\/\?\%\*\:\|\"<>]+$')
its work for me. Basically it takes:
new RegExp('^[^\\/?%*:|"<>]+$')
