Helaas: het is dus geen normele reguliere expressie wat men gebruikt; 'X-Spam-Level: \*{5}' werkt niet.
Bij deze de hulp die in Pegasus staat:
Regular expression syntax
A regular expression is simply a way of defining a pattern of characters you would like to match. This kind of pattern matching is something the human mind does instinctively, but computers need to be given rules describing how it should be done on a case by case basis.
In Pegasus Mail, a regular expression consists of text characters and metacharacters. A text character is simply a piece of invariant text that must appear in the data you are attempting to match, while a metacharacter is a special character that matches some arbitrary pattern. This is all a little too much like jargon, so let's take a simple example:
Say you want to define an expression that matches any string containing "sorry Dave"; in this case, the text characters are "sorry Dave", and you need a special way of matching any text on either side of them. In this case, that "special way" is to use a metacharacter, "*", which Pegasus Mail interprets as meaning "match anything". So, to match any string containing "sorry Dave", we need to match anything preceding our text characters, then match the text characters "sorry Dave", then finally we need to match anything following our text characters. The regular expression we need to give Pegasus Mail to achieve this is "*sorry Dave*".
By combining metacharacters and text characters, it is possible to create patterns that can match almost any type of text. Pegasus Mail supports the following metacharacters in regular expressions:
* Match any number of any characters
? Match any single character
+ Match one or more occurrence of the last character
[ ] Encloses a group of characters to match. Ranges can
be specified in the group using '-'.
Let's look at one or two of these a little more closely:
* You'll probably use this metacharacter most often: it means "match anything" - which also includes "nothing". So, in our example above, Pegasus Mail will match the string "sorry Dave, I can't do that", even though there is nothing in front of the matching text characters.
? This matches any one character. Unlike *, it will always match at least one character - it won't match nothing. So, the expression "?? cat" will match the string "My cat", but it will not match the string "A cat", because there are too few characters before the text characters.
+ You'll normally use this to match a repeated occurrence of a character when you don't know in advance how many there might be. The most common use is to match space characters - so, the expression "A +cat" will match "A cat", "A cat" or "A cat".
[] Say you only want to match the digits 0-9: that's where the square brackets come in. The expression "[0-9]" tells Pegasus Mail to match any single character as long as it is 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. Like the ? metacharacter, this matches exactly one character. You can use quite extensive ranges and combine them with single characters - for instance, the expression "[0-9a-exyz]" will match any digit, any letter from A to E, an X, a Y or a Z. You can combine range matching like this with the + metacharacter to match similar groups of characters: so, if you want to match any number, you could use the expression "[0-9]+", which would match "1", "123", "12304567" and so on.
It is important to remember that Pegasus Mail always attempts to match regular expressions on a line by line basis, starting at the beginning of the line. Imagine that we had written our example expression as "sorry Dave*" (no leading * metacharacter): Pegasus Mail understands this to mean match any expression as long as it starts with "sorry Dave" - it would no longer match a line where this string occurred further on in the line.
Regular expressions in Pegasus Mail are always case-insensitive - that is, lowercase and uppercase text is treated as the same. So, "SORRY DAVE" is treated exactly the same as "sOrRy DaVe".
Ik heb net ook nog "*X-Spam-Level: [*****]*" geprobeerd, maar die filtert ook mails met drie sterretjes.
[
Voor 96% gewijzigd door
pven op 11-04-2004 11:32
]