You are not logged in.

#1 2007-01-15 14:31:47

hypermegachi
Member
Registered: 2004-07-25
Posts: 311

who's good with regular expressions?

i'm trying to get blockhosts to work, but i don't think it's matching.

here's a snippet from my auth.log

Jan 15 09:28:11 myhostname (IDLE)[19960]: (?@217.26.64.149) [WARNING] Authentication failed for user [admin]

here's the regex that should match it in /etc/blockhosts.cfg

"PureFTPD-Fail": re.compile(r"""pure-ftpd: (?@(?P<host>d{1,3}.d{1,3}.d{1,3}.d{1,3})) [WARNING] Authentication failed"""),

call me lazy, but i'm sure some expert here can solve this in 2 seconds while it would take me 2 hours to figure out the syntax.

thanks!

Offline

#2 2007-01-15 14:43:15

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: who's good with regular expressions?

It's clear that your regex will miss this line. For starters, your regex is looking for a match to find 'pure-ftpd:' which doesn't exist in your sample line. Also, your RE expects a match to end with 'Authentication failed'. Again, this is not the case in you sample line.

I don't see why you need the r"""...""". What's wrong with single quotes?

That aside, if you change your RE to

re.compile(r'(?@(?P<host>d{1,3}.d{1,3}.d{1,3}.d{1,3})) [WARNING]')

Then then 'host' group is matched ok.

Get hold of Pyreb (in the AUR) for testing with REs.

Offline

Board footer

Powered by FluxBB