List:General Discussion« Previous MessageNext Message »
From:Christian Hammers Date:November 8 2006 7:04pm
Subject:Re: Regular expression not working as expected (documented)?
View as plain text  

On 2006-11-08 Leandro Guimarães Faria Corcete DUTRA wrote:
> > >         u.login REGEXP
> '^wa[bhkl][_[.period.]-acegmnopqrsuvwxyz]{1,5}[14Lt][23890IJOQ].*...
> > > But I get, among otherss, a string beginning with 'walt' (several, in
> fact).
> > 
> > Probably MySQL don't know about this "[.period.]" thing and just takes the "."
> in it
> > as "any char", e.g. your "t" from "walt".
> 
> 	I got that from cname.h, mentioned in the MySQL regexp documentation.
> 
> > Try '^wa[bhkl][-_acegmnopqrsuvwxyz]{1,5}[14Lt][23890IJOQ].*', if there is a "-"
> at the
> > beginning of a character class it is usually threaten literally as it makes no
> sense
> > as "from..to" separator in those cases.
> 
> 	Hm, but I do need to take into account the period.
Right, the "[.period.]" really exists, so you can safly insert it. But only *after* 
this "-" character!

> 	Also, do you mean the - at the beginning will make all following
> characters be treated literally?
Hm, no, the "-" inside "[" and "]" is a special character, i.e. "[a-z]" means all chars
from a to z. So in your case that would have been all chars from . to a which makes not
much sense. If you write "[-az]" on the other hand that means the dash char or a or z.
So just move the "-" right after the "[" and you're done.

"walt12" -> false
"wal.12" -> true
"wala12" -> true

bye,

-christian-
Thread
Regular expression not working as expected (documented)?Leandro Guimarães Faria Corcete DUTRA8 Nov
  • Re: Regular expression not working as expected (documented)?Christian Hammers8 Nov
    • Re: Regular expression not working as expected (documented)?Leandro Guimarães Faria Corcete DUTRA8 Nov
      • Re: Regular expression not working as expected (documented)?Dan Nelson8 Nov
        • Re: Regular expression not working as expected (documented)?Leandro Guimarães Faria Corcete DUTRA8 Nov
      • Re: Regular expression not working as expected (documented)?Christian Hammers8 Nov
    • RE: Regular expression not working as expected (documented)?Jerry Schwartz8 Nov