On 3 Aug, Hanspeter Roth wrote:
| Hello,
|
| obviously the regular expressions in procmail are similar as those
| of egrep. So it seems there is no backreference \1.
|
| I want to use something like [0-9]\1\1 to match a sequence of three
| equal digits. This should match 111 and 222 but not 122.
|
| Is there something equivalent in procmail/egrep?
|
Not exactly, but it can be done using the contents of $MATCH as assigned
by the MATCH token "\/".
# thisrc
DEFAULT = /dev/null
NL="
"
VAR = ${VAR:-666}
:0
* VAR ?? ()\/[0-9]
* $ VAR ?? ()\/$MATCH$MATCH$MATCH
{ LOG = "Matched $MATCH$NL" }
Watching it in action (at a shell prompt) ...
$ procmail VAR=555 ./thisrc </dev/null
Matched 555
$ procmail VAR=567 ./thisrc </dev/null
$ procmail ./thisrc </dev/null
Matched 666
It's covered in man procmailrc, but bacically procmail assigns any
match after the \/ token to the variable $MATCH.
N.B. Don't forget the leading $ on the second condition to have $MATCH
expanded. Also, if the \/ token is used at the beginning of the
regular expression it needs to be preceded by () as above, or it needs
to be \\/. This is to prevent the leading \ being taken as a literal.
--
Reply to list please, or append "8" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail