procmail
[Top] [All Lists]

Re: Regexp bug ? \<(word|word)\> does not match

2000-09-01 09:11:33
Andre asked,

| Hello folks. I've found that the regexp engine in procmail v3.15
| 2000/08/25 does not seem to be able to find matches for a regexp
| like
| 
|   \<(several|words|to|match)\>

I'm guessing that the problem is that you have that at the very beginning
of the expression, so procmail strips off the first backslash to mean "end 
of rcfile whitespace, start of regexp" and then looks for a literal left-
side angle bracket, followed by any of the words, followed by a non-word
character.  Since you don't have the literal left-side angle bracket in
the text, there never is a match.

There are two basic methods to work around it:

   \\<(several|words|to|match)\>
or
   ()\<(several|words|to|match)\>

Most of us prefer the second, because the first is counterintuitive: one
expects "\\" to represent a literal backslash, not two magic ones.

| I've worked around it by using \<several\>|\<words\>|... instead ...

Now there, the backslash gets stripped only before "<several" and nowhere
else.  I'll bet that, if the matching word in the text is the first one in
the list it still won't match, but the rest of the words work.

| For what it's worth, GNU egrep has no problem with it.

For what it's worth, when you use GNU egrep, you have the expression properly
quoted, don't you?  Then the backslash doesn't get stripped.


_______________________________________________
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>