Thanks very much Julio!  That answers it!


On 25-11-2016 04:29, pjc904@... wrote:
>          Thanks very much for that explanation and the link.  That
>          explains the %(whatever)s part of the expression, but what
>          about the (?:  ...  )     ...is that Python too?  Does it mean

I can answer this one. It's Python regex syntax.

https://docs.python.org/3/library/re.html

Cheers.

Júlio

On Thu, Nov 24, 2016, at 10:29 PM, [email protected] wrote:
> Tom,
>          Thanks very much for that explanation and the link.  That
>          explains the %(whatever)s part of the expression, but what
>          about the (?:  ...  )     ...is that Python too?  Does it mean
>          to interpret whatever is enclosed in this expression as
>          "Python" first - rather than as a regular expression?    If so,
>          would you happen to know what that operator is called in Python
>          ...or better yet would you be able to point me in the direction
>          of a Python doc that explains it?  
> 
> Thank you very much!
> 
>          
> On Thu, Nov 24, 2016, at 12:41 PM, Tom Hendrikx wrote:
> > Hi,
> > 
> > That is indeed not regular expression syntax, it is python string
> > formatting, used to generate the regex. This string is used also in the
> > fail2ban config files in various distros to setup jails (although I
> > think that the config file gets less readable from this, especially for
> > non-programmers, but none of that is related to your question).
> > 
> > See
> > https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting
> > for details on %(...)s syntax.
> > 
> > Regards,
> >     Tom
> > 
> > On 24-11-16 21:17, [email protected] wrote:
> > > Hello,
> > >      I'm new to this list.  I'm familiar with regular expressions but
> > > there's one aspect of failregex's that I do not understand - the nesting
> > > aspect.  Take, for instance, this example from "apache-badbots.conf"
> > > which comes with the installer in the filters.d/ directory:
> > > 
> > > badbotscustom = EmailCollector|WebEMailExtrac|TrackBack/1\.02|sogou
> > > music spider
> > > badbots =
> > > Atomic_Email_Hunter/4\.0|atSpider/1\.0|autoemailspider|bwh3_user_agent  
> > > ...etc...etc...etc...
> > > 
> > > failregex = ^<HOST>
> > > -.*"(GET|POST|HEAD).*HTTP.*"(?:%(badbots)s|%(badbotscustom)s)"$
> > > 
> > > 
> > > The part that I don't understand is this: 
> > > "(?:%(badbots)s|%(badbotscustom)s)"
> > >    ...If that is a part of standard Posix regular expressions (or perl
> > > extensions), I was not aware of it.  So what is it?  I can see that the
> > > "%(badbots)" is probably getting replaced by the big long or'ed regular
> > > expression above ...but what about the "s" after the last closing
> > > parenthesis?  And I do not understand the "(? ... )"  ...what does it
> > > mean to have an expression that is entirely enclosed in this
> > > parenthesized expression with a question mark after the first opening
> > > parenthesis? 
> > > 
> > > Thanks in advance for any help.
> > > 
> > > 
> > > ------------------------------------------------------------------------------
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > Fail2ban-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/fail2ban-users
> > > 
> > 
> > 
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > Fail2ban-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/fail2ban-users
> > Email had 1 attachment:
> > + signature.asc
> >   1k (application/pgp-signature)
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Fail2ban-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fail2ban-users

------------------------------------------------------------------------------
_______________________________________________
Fail2ban-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fail2ban-users

Reply via email to