Postmaster filter - regular expression "but not"

Moderator: crythias

Post Reply
andy17d
Znuny newbie
Posts: 78
Joined: 30 Jan 2014, 15:27
Znuny Version: 4.0.19
Location: Poland
Contact:

Postmaster filter - regular expression "but not"

Post by andy17d »

I'm trying to set up a filter tickets that contains the words xxx or yyy but not zzz.

I set the field body Look for value: .*(xxx|yyy).*
and body - negation - Look for value: .*(zzz).*

Unfortunately, it does not work, because the second body condition disappears.
OTRS 4.0.19/6.0.26, openSUSE 12, MySQL 5.5

KodIT Usługi Informatyczne - Odzyskiwanie danych Poznań - Serwis Komputerowy
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Postmaster filter - regular expression "but not"

Post by reneeb »

I hope I've covered all possibilities:

Code: Select all

#!/usr/bin/perl

use v5.10;

use strict;
use warnings;

my @strings = ('xxx yyy zzz', 'xxx zzz', 'xxx yyy', 'yyy zzz', 'aaa yyy', 'aaa bbb', 'xxx bbb', 'aaa xxx', 'yyy abc', 'zzz yyy', 'zzz abc', 'abc zzz');
for my $string ( @strings ) {
    say $string, ": ", ($string =~ m{^(?!.*zzz)(?=.*(?:xxx|yyy))(?!.*zzz)}xms);
}
So try

Code: Select all

^(?!.*zzz)(?=.*(?:xxx|yyy))(?!.*zzz)
in your filter
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
andy17d
Znuny newbie
Posts: 78
Joined: 30 Jan 2014, 15:27
Znuny Version: 4.0.19
Location: Poland
Contact:

Re: Postmaster filter - regular expression "but not"

Post by andy17d »

Thank you very much for your help! It seems to be good.
OTRS 4.0.19/6.0.26, openSUSE 12, MySQL 5.5

KodIT Usługi Informatyczne - Odzyskiwanie danych Poznań - Serwis Komputerowy
Post Reply