Postmaster filter - regular expression "but not"

Moderator: crythias

andy17d
OTRS expert
Posts: 57
Joined: 30 Jan 2014, 15:27
OTRS Version?: 4.0.19
Location: Poland
Contact:

Postmaster filter - regular expression "but not"

Postby andy17d » 23 Oct 2017, 13:06

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, openSUSE 12, MySQL 5.5

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

reneeb
OTRS guru
Posts: 4363
Joined: 13 Mar 2011, 09:54
OTRS Version?: 3.3.x
Company: Perl-Services.de
Contact:

Re: Postmaster filter - regular expression "but not"

Postby reneeb » 23 Oct 2017, 15:18

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 / OTRS development: http://perl-services.de
Free OTRS add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de

andy17d
OTRS expert
Posts: 57
Joined: 30 Jan 2014, 15:27
OTRS Version?: 4.0.19
Location: Poland
Contact:

Re: Postmaster filter - regular expression "but not"

Postby andy17d » 24 Oct 2017, 11:29

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

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


Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests

cron