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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -