Someone check my regex please

These are old archives. They are kept for historic purposes only.
Post Reply
White_Magic
Posts: 267
Joined: Tue Jan 18, 2005 3:24 pm
Location: Scotland - United Kingdom

Someone check my regex please

Post 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].*@.*:.*
Syzop
UnrealIRCd head coder
Posts: 2112
Joined: Sat Mar 06, 2004 8:57 pm
Location: .nl
Contact:

Re: Someone check my regex please

Post 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)
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post by aquanight »

Why use two regexes?

^.+![a-z]([a-z]{3})?[0-9]{4}@.+:.+$
White_Magic
Posts: 267
Joined: Tue Jan 18, 2005 3:24 pm
Location: Scotland - United Kingdom

Post by White_Magic »

im getting better i promise :D
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

Post 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*
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
White_Magic
Posts: 267
Joined: Tue Jan 18, 2005 3:24 pm
Location: Scotland - United Kingdom

Post 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,
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

Post by w00t »

ta muchley, im getting there :)
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
Post Reply