Hi all, I'm trying to create a filter rule based on a REGEX applied to the From field, let me explain with an example. Let's consider the following users: John Samuelson John Larryson John Smithson John Somethingotherson John Samuelson is a regular person and I don't want to filter it, but often there are other "morphing users" that have fun spamming with a similar name as shown above. I want to filter just them. So, my filter has to match just: John Larryson John Smithson John Somethingotherson Now, the first question is: what REGEX types does tin supports? POSIX? Perl compatible? or what else? I'm testing some regex with "grep" and the following command seems to work fine: grep -P 'John\s\b(?!Samuelson).*son\b' input-names.txt It matches just the morphing users, bu the problem is that the above "-P" option in grep command activates the Perl compatible regex and I don't know if that is supported also by tin filter. Thank you a lot in advance!
On Fri, Oct 20, 2017 at 02:21:17PM +0200, Joe wrote:
Now, the first question is: what REGEX types does tin supports?
perl compatible (pcre is used as engine) if wildcard=1 in tinrc.
grep -P 'John\s\b(?!Samuelson).*son\b' input-names.txt
lookahead paterns are supported, so that group=* case=0 score=kill from=John\s\b(?!Samuelson).*son\b should work or you could use scooring give enery article that matches John\s+.*son\b a score of eg -100 and the ones which match John\sSamuelson a score of 100 at the end John\sSamuelson gets a score of 0 as he matches both filters so his articles are "untouched", but the other John *son are killed. group=* case=0 score=kill from=John\s+.*son\b group=* case=0 score=hot from=John\sSamuelson\b
Thank you, I had solved by trying a rule like the following: ------------ comment=example group=ex.ample case=0 score=kill from=.*(?!samuelson).*son\.yada@example.net\s\(John\s\b(?!Samuelson).*son\b\).* ------------- My original regex was based on a pattern like: John somethingson <somethingson@example.net> Then, after a better reading of the tin man and filtering.txt docs, I realize it converts the From field to an old-style format before trying the regex. So I should have considered a different pattern based on something like the following: somethingson@example.net (John somethingson) And finally I reached my goal with the above reported REGEX. Your confirm about the tin compatibility with PCRE regex is very useful along your explanation about scoring! Anyway, just for curiosity, where this information (I mean tin filtering regex are in pcre style) is "formally" written? I couldn't find it on the man pages nor at the site docs... Thank you a lot for your reply! Bye! On Fri, Oct 20, 2017 at 6:06 PM, Urs Janßen <urs@tin.org> wrote:
On Fri, Oct 20, 2017 at 02:21:17PM +0200, Joe wrote:
Now, the first question is: what REGEX types does tin supports?
perl compatible (pcre is used as engine) if wildcard=1 in tinrc.
grep -P 'John\s\b(?!Samuelson).*son\b' input-names.txt
lookahead paterns are supported, so that
group=* case=0 score=kill from=John\s\b(?!Samuelson).*son\b
should work or you could use scooring
give enery article that matches John\s+.*son\b a score of eg -100 and the ones which match John\sSamuelson a score of 100 at the end John\sSamuelson gets a score of 0 as he matches both filters so his articles are "untouched", but the other John *son are killed.
group=* case=0 score=kill from=John\s+.*son\b
group=* case=0 score=hot from=John\sSamuelson\b
_______________________________________________ tin-users mailing list tin-users@tin.org http://lists.tin.org/cgi-bin/mailman/listinfo/tin-users
On Sun, Oct 22, 2017 at 02:52:52PM +0200, Joe wrote:
Anyway, just for curiosity, where this information (I mean tin filtering regex are in pcre style) is "formally" written? I couldn't find it on the man pages nor at the site docs...
It can be found in the man page (tin(1)) under 'Wildcard matching': | Wildcard matching (wildcard) | Allows you to select how tin matches strings. The default is | 0 and uses the wildmat notation, which is how this has | traditionally been handled. Setting this to 1 allows you to | use perl(1) compatible regular expressions pcre(3) (see also | perlre(1) and pcrepattern(3)). You will probably want to | update your filter file if you use this regularly. NB: | Newsgroup names will always be matched using the wildmat | notation. and in tin(5) under 'wildcard'. Dennis
Thank you! I should have read the man page better! Thanks again bye On Sun, Oct 22, 2017 at 3:18 PM, Dennis Preiser <dennis@d--p.de> wrote:
On Sun, Oct 22, 2017 at 02:52:52PM +0200, Joe wrote:
Anyway, just for curiosity, where this information (I mean tin filtering regex are in pcre style) is "formally" written? I couldn't find it on the man pages nor at the site docs...
It can be found in the man page (tin(1)) under 'Wildcard matching':
| Wildcard matching (wildcard) | Allows you to select how tin matches strings. The default is | 0 and uses the wildmat notation, which is how this has | traditionally been handled. Setting this to 1 allows you to | use perl(1) compatible regular expressions pcre(3) (see also | perlre(1) and pcrepattern(3)). You will probably want to | update your filter file if you use this regularly. NB: | Newsgroup names will always be matched using the wildmat | notation.
and in tin(5) under 'wildcard'.
Dennis
_______________________________________________ tin-users mailing list tin-users@tin.org http://lists.tin.org/cgi-bin/mailman/listinfo/tin-users
participants (3)
-
Dennis Preiser -
Joe -
Urs Janßen