PHPVerbalExpressions icon indicating copy to clipboard operation
PHPVerbalExpressions copied to clipboard

anythingBut and a range doesn't work

Open AurelienMendes opened this issue 6 years ago • 1 comments

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

AurelienMendes avatar Jan 29 '19 13:01 AurelienMendes

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.

wangpeipei90 avatar May 02 '19 15:05 wangpeipei90