用于验证directry路径的正则表达式

时间:2017-12-12 08:30:51

标签: php regex

我已经尝试使用以下正则表达式,但它没有按预期工作(xampp php)

$slug = "test123/abc_xyz-001" //this is valid

$reg = '/^[a-zA-Z0-9_-/]+$/';

if (preg_match($reg, $slug)) { // the slug shoul only contain the combination of alpha numeric and _ - /
    //It is a valid path
}
else{
    //not valid 
}

有效案例

ABC

123

abc12d3

abc_123s

ABC-XYZ

test123 / abc_xyz-001

0 个答案:

没有答案
相关问题