procmail
[Top] [All Lists]

Re: Whitespace regex

2000-11-18 14:04:16

Well, you don't have to wait for procmail to get an updated regex
syntax if you are willing to use a preprocessor. I use a perl script
to munge my procmail source into legit rc files, spitting out valid
procmail regex strings for the ~ sequences, and also stripping
comments like those shown here. The hash below is one part of it.
This allows me to construct conditions like the following:

    * ^received:~c\/~S.+                ## grab received header text
    * ^~e~E~9+(~s*$)*^^                 ## ^[^(_at_)99 at end
    * MATCH ?? ()\/~S(.*($.*)*~S)?      ## trim leading & trailing ws and eol

Adding code to handle {m,n} is low on my list of changes.

# hash of tilde-quotes and their replacements. See note 2 in WARNINGS,
# above, and substitution procedures below, for details on operation
my %tilde=('A', 'A-Z',              'a', 'a-z',          # A ALPHA a alpha
        'C', "\xA2", 'c', "[ \t]*(\\([^()]*\\)[ \t]*)*", # C CENT c rfc ws
        'E', "[^\x1-\xFF]",         'e', "\e",           # E NULL    e ESC
        'H', '[^-a-z0-9.]',         'h', '[-a-z0-9.]',   # H !host  h host
        'm', "[-!#-'*+/-9=?a-z^-~]",                     # m rfc822 atom
        'N', "\xA0",                'n', "\n",           # N NBSP     n nl
        'S', "[^ \t]",              's', "[ \t]",        # S [!ws]  s [ws]
        't', "\t",                                       # t tab
        'U', '[^-a-z0-9_.]',        'u', '[-a-z0-9_.]',  # U !user  u user
        'w', " \t",                                      # w ws
        'X', 'a-z0-9',              'x', '[0-9a-f]',     # X alnum   x hex
        'Z', '[A-Z]',               'z', '[a-z]',        # Z [~A]   z [~a]
        '0', '0-9',                 '9', '[0-9]',        # 0 num    9 [~0]
        '#', '#',                   '~', '~',            # # #         ~ ~
        '+', "[\x80-\xFF]",         '?', "\xBF");        # + hibit  ? inv?
-- 
Rik Kabel      old enough to be an adult      rik(_at_)panix(_dot_)com
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>