Using - in REGEX mySQL query -


i'm trying create query in mysql, can match:

a-z 0-9 _  - . / 

thus far, have:

update errors set been_checked = 1 binary(request) regexp "^[a-z0-9_./]+$" , been_checked = 0 

this works, don't have - 1 of characters. so, i'm trying:

update errors set been_checked = 1 binary(request) regexp "^[a-z0-9_-./]+$" , been_checked = 0 

...but gives me error:

error: not execute query: failed execute query: 'update errors set been_checked = 1 binary(request) regexp "^[a-z0-9_-./]+$" , been_checked = 0': got error 'invalid character range' regexp

i've tried using \- , doesn't work either.

how use - part of matching string?

thanks

you need put hyphen @ start or end of character class or escape it.

[-a-z0-9_./] 

else hyphen indicates character range inside class.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -