PHPVerbalExpressions
PHPVerbalExpressions copied to clipboard
anythingBut and a range doesn't work
Hello,
It seems it's not possible to do something like:
$regex->anythingBut('0-9')
since the sanitize method add systematically a "\" behind the "-" which break the regex range expression. That giving us:
(?:[^0\-9]*)
instead of
(?:[^0-9]*)
Thanks a lot, Aurélien
I found similar problems with the anythingBut function. If I do anythingBut('test'), it actually turns the regex to be [^test], which not only disallow "test" but also any other words containing t, e, s.
From my point of view, escaping any non-word char with two backslashes is not enough for the function or the value passing into it needs to be restricted.