需要处理的要求:
only ascii letters in lower register [a-z], digits [0-9], "/" and "-"
the string should begin with "/"
"/" and "-" should not stand next to each other nor self in ANY combination
string must end with a ascii letters in lower register [a-z], digits [0-9] and "/"
到目前为止:
^((?:(?![0-9a-z\/\-]*?(\/|\-)(\/|\-)))\/[0-9a-z\/\-]*?[0-9a-z\/]$)
链接到调试regex debugger
答案 0 :(得分:1)
如果我理解你的要求,你可以使用这种模式:
\A/(?>[a-z0-9]+[-/])*[a-z0-9]++/?\z