Page 1 of 1

Someone check my regex please

Posted: Thu Feb 03, 2005 10:47 pm
by White_Magic
bots with idents of -
1) 1letter4numbers
2) 4letters4numbers

are bothering us, anybody tellme this regex is correct to stop them?

.*![a-z][0-9][0-9][0-9][0-9].*@.*:.*
.*![a-z][a-z][a-z][a-z][0-9][0-9][0-9][0-9].*@.*:.*

Re: Someone check my regex please

Posted: Thu Feb 03, 2005 10:55 pm
by Syzop
.*![a-z][0-9][0-9][0-9][0-9].*@.*:.*
.*![a-z][a-z][a-z][a-z][0-9][0-9][0-9][0-9].*@.*:.*
well yes that would work.
But you probably would want to have fun with the repeat thingy, so:

Code: Select all

.*![a-z][0-9]{4}.*@.*:.*
and actually.. if the ident is just 1 letter + 4 digits and nothing more.. then you probably do not want a .* there, so:

Code: Select all

.*![a-z][0-9]{4}@.*:.*
or what I would use (^ means start at the beginning, .+ means match 1 or more)..

Code: Select all

^.+![a-z][0-9]{4}@.+:.+
(similar stuff for other regex)

Posted: Thu Feb 03, 2005 11:04 pm
by aquanight
Why use two regexes?

^.+![a-z]([a-z]{3})?[0-9]{4}@.+:.+$

Posted: Thu Feb 03, 2005 11:52 pm
by White_Magic
im getting better i promise :D

Posted: Fri Feb 04, 2005 12:21 am
by w00t
aquanight wrote:Why use two regexes?

^.+![a-z]([a-z]{3})?[0-9]{4}@.+:.+$
ofc, i could be wrong... but should that be:
^.+![a-z]([a-z]{4})?[0-9]{4}@.+:.+$

(1/4 letters, 1/4 numbers)
remembering that im just starting out with regexs :P

*edit* fixed bloody bbcode *edit*

Posted: Fri Feb 04, 2005 12:28 am
by White_Magic
w00t wrote:
aquanight wrote:Why use two regexes?

^.+![a-z]([a-z]{3})?[0-9]{4}@.+:.+$
ofc, i could be wrong... but should that be:
^.+![a-z]([a-z]{4})?[0-9]{4}@.+:.+$

(1/4 letters, 1/4 numbers)
remembering that im just starting out with regexs :P

*edit* fixed bloody bbcode *edit*
no becuz there is 1 [a-z] out of the sub expression,

Posted: Fri Feb 04, 2005 12:31 am
by w00t
ta muchley, im getting there :)