[Linux-aus] python regex

Nick Edwards nick.z.edwards at gmail.com
Mon Oct 7 17:43:50 EST 2013


Since this list seems to have a few python experts going by the
previous thread, wondering if one can offer some advice

This is a fail2ban regex, seeking out nothing, or ",something", by this  mean

TLS/SSL connections will only match  rip=(?P<host>\S*),.*

But plain connections will only match on rip=(?P<host>\S*)

neither includes the other, so at present we have duplication

(other_specific_matching_criteria).*rip=(?P<host>\S*)
to match on plain, and
(other_specific_matching_criteria).*rip=(?P<host>\S*),.*      to match
on ,SSL/TLS/secure/whatever

these rules work, but surely there is a way to have one command, that,
doesnt care if what it wants ends at host bit, or carries on, in perl
this is deal simple, but not so in python

I have tried .*    since . is supposed to be 0 or 1, I have also tried .*?
and a bunch of other variations.

Any suggestions?

Nikki



More information about the linux-aus mailing list