Re: [exim] Regexps (was: ACL filtering)

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Eduardo M KALINOWSKI
Data:  
Para: exim users
Temas antigos: Re: [exim] ACL filtering
Asunto: Re: [exim] Regexps (was: ACL filtering)
On 04/23/2010 09:11 PM, Always Learning wrote:
>
> Thank you for clearly explaining my misunderstanding.
>
> Your helpful explanation is very useful. Now I know why the gaps between
> the criteria letters (adsl) was not being processed in the way I had
> expected. I have changed my test to:
>
> deny    message       = [C06.5]  Msg6 Msg2
>          hosts         =
> ^.*[a](1)[-_.](.?)[d](1)[-_.](.?)[s](1)[-_.](.?)[l](1).*

>
>
>
> ^ = beginning of string
>
> .* = any quantity, or none, of any characters
>
> [a](1) = match only one 'a'
>


No, that would match an 'a', followed by a '1', storing the 1 in a
matched group. To specify the number of matches one uses curly braces:
{1}. However, it is redundant to specify {1}: if you want exactly one
match, just specify what you want matched. "[a]{1}" and "[a]" are the same.

Furthermore, [...] means one of the characters inside the brackets:
"[ab]" is either a or b. If there is only one character, there is no
need for brackes: just specify them.

In short, to match one 'a', use "a".

> [-_.](?) = match next character which should be one or nil occurrences
> of .-_
>


To match zero or one of an expression, use "?", not "(?)" (which is
seems like an illegal regexp - I wonder how it gets parsed). And I
believe you meant one or nil of one of the characters .-_

> [d](1) = match only one 'd'
>
> [-_.](?) = match next character which should be one or nil .-_
>
> [s](1) = match only one 's'
>
> [-_.](?) = match next character which should be one or nil .-_
>
> [l](1) = match only one 'l'
>
> [-_.](?) = match next character which should be one or nil .-_
>
> .* = any quantity, or none, of any characters
>


Repeat.

While to geared towards exim, these tutorials are quite useful:
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlretut.html

Or google "regexp tutorial", there's bound to be dozens of useful resources.

--
A closed mouth gathers no foot.

Eduardo M KALINOWSKI
eduardo@???