Closed NTT1906 closed 1 year ago
I am not really a fan of using character classes. They differ across implementations and actually reduce readability since it is not always obvious to remember what they mean (are they just alphabets? does w
mean "whitespace" instead of "word"?). I would rather not use them unless they significantly reduce the regex complexity like \b
.
and the ?:
doesn't look necessary anyway
then ^([a-zA-Z0-9_]+(\\\\)?)+$
?
Trailing backslashes are explicitly disallowed. That's the main point of this regex check.
Trailing backslashes are explicitly disallowed. That's the main point of this regex check.
if (str_ends_with($epitope, "\\")) { throw new RuntimeException("epitope must not end with a backslash"); }
if so, this code won't be executed?
Right, those lines are redundant indeed, but let's just leave it there
Old original: https://rubular.com/r/rbFHtoKeXfTOIb
^[a-zA-Z0-9_]+(\\\\[a-zA-Z0-9_]+)+$
Group-based: https://rubular.com/r/n97pophwFTVzlf^(?:[\w]+(?:\\\\)?)+$
, this allowstes_1t\\dir\\
Currently using: https://rubular.com/r/u2chZTVA19hZKj^\w+(?:\\\\\w+)+$
, this allowstes_1t\\dir