procmail
[Top] [All Lists]

Re: about procmail regex operators

2010-03-27 11:23:43
On Sat, Mar 27, 2010 at 9:06 AM, Harry Putnam <reader(_at_)newsguy(_dot_)com> 
wrote:
Where to get a succinct review of regex operators in procmail?

Find a copy of the manual for SunOS "egrep" from approximately 1989.

Do we have any kind of counting operator like those in perl?

No ... but it does have scoring, so you can compare first and count
the number of matches afterward.  E.g.:

:0
* -15^0
*   1^1 [a-zA-Z0-9]
{ LOG="Matched $= alphanumerics, at least 16
" }

I want to specify a number of occurrences [a-zA-Z0-9] But the number
is too high to be able to write it out neatly, it would take probably
15-18 repeats of the regex [a-zA-Z0-9].

The technique I've seen used for this for this is along the lines of:

RE1="[a-zA-Z0-9]"
RE2="$RE1$RE1"
RE4="$RE2$RE2"
RE8="$RE4$RE4"
RE16="$RE8$RE8"

RE15to18="$RE16?($RE1$RE2)?"

Maybe another approach would be to use the [^] operator?

Yes.
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail