procmail
[Top] [All Lists]

Re: Range matching

2000-11-09 08:26:23
Anthony -

I think there are two things wrong. First, I don't believe procmail's
regular expression engine groks the {n,m} repetition operator. I am
going from memory on this one, so you should check the man pages.
Second, your example indicates that there could be more than one space
between "Subject:" and "Report". Your use of "." in the expression will
match exactly one of *any* character. So assuming that there can be only
whitespace in that position, but any amount of it, I'd suggest:

* ^Subject:[    ]*Report[       ]*[0-9][0-9][0-9]?\>

Inside the bracket pairs are a space and a tab. Each of these will match
zero or more, so if you want to enforce required whitespace you'll have
to adjust this. (e.g. if you know there is only one space character,
replace the bracketed character class with a single space character; if
it can be a space or a tab, but only one of either, remove the trailing
'*'; if there must be at least one, then add a second character class
without the trailing '*'.)

Finally, this expression will match your parameters and more. In other
words, "Subject: Report 345 - send it" will match. If you want to
enforce that nothing else can appear in the Subject header, replace the
word boundary expression (\>) with '$' to match the end of line. In
this case, you may want to allow for "meaningless" whitespace between
the number and the '$'.  Note also I've anchored the expression to the
beginning of the line with '^', which I suppose is not terribly
important if only matching headers - but doesn't hurt.

 - Don


On  9 Nov, Anthony Seddon wrote:
| Question:
| How do I build an expression that will range match?  
| 
| Example
| I want to match the following;
| Subject:  Report 677   or  
| Subject: Report 65      but not
| Subject: Report 1       or
| Subject: Report 3212
| 
| My expression here would be.... *Subject:.Report.[0-9]\{2,3\}
| 
| I.e. I want to match where the Subject starts with "Report" followed by
| either 2 or 3 digits.  The above expression does not match the examples
| provided although it should.
| 


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