我想检查给定的字符串是否是PHP文件的文件路径,但失败了。 :(
// function: is string a path to PHP file?
var isFilepath = str =>(
/^[a-z]:((\\|\/)[a-zA-Z0-9\s_@\-^!#$%&+={}\[\]]+)+\.php$/i.test(str)
);
// example how I am actually trying to apply it
var str = '../lib/ajax/pDetails.php';
if( isFilepath(str) ){
console.log('Yes, it is a filepath.');
}
也许,