PostMaster Filter RegEx question

Moderator: crythias

Locked
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

PostMaster Filter RegEx question

Post by Mothra »

Does the Postmaster Filter in the Admin UI support regex backreferences. I'm thinking specifically of capturing something in the filter and then reusing part of it in the "Set Email Headers" section. Is this possible? If so, how?

Btw, I have no problem using the Postmaster Filter modules; just that keeping the email filtering rules in the Admin UI makes them more visible to less experienced OTRS admins (which is who I will be leaving behind after this contract).
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: PostMaster Filter RegEx question

Post by crythias »

Items matched within parentheses () will fill [***] in set.

Match: (username)@domain
Set: X-OTRS-CustomerUser [***]
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Re: PostMaster Filter RegEx question

Post by Mothra »

crythias wrote:Items matched within parentheses () will fill [***] in set.

Match: (username)@domain
Set: X-OTRS-CustomerUser [***]
This is what I thought, based on the example in Core::Postmaster, but for some reason, I can't get it working. What's the significance of three asterisks - should there be more if I'm matching more than one character?

I've got

Code: Select all

Match:  Subject = ^\[Ticket\#([0-9]+)\]

Set:  
X-OTRS-Queue = Legacy Tickets
X-OTRS-TicketKey1 = Legacy Ticket Number
X-OTRS-TicketValue1 = [***]
A ticket with Subject starting "[Ticket#201101041001123]" ticket is moved to the right queue, and the free fields are populated, except the TicketValue1 ends up being a single digit - 3 in the example above where it should be 201101041001123. At first I thought my regex might be duff, but I've checked it in a Perl script and it seems to be okay.

EDIT: The Perl script that works...

Code: Select all

#!/bin/perl -w
use strict;
my $ticketNum = '[Ticket#201101041023456] Problem with some issue';
if($ticketNum =~ m/^\[Ticket\#([0-9]+)\]/) {
        print "The ticket number is $1.\n";
}
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: PostMaster Filter RegEx question

Post by crythias »

3 asterisks is (apparently) simply the only placeholder for the first thing that was matched above.

^\[Ticket\#([0-9]{15})\] forces checking for a 15 digit number. I wonder if it will help.
Alternatively.. (ick)
^\[Ticket\#(\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d)\]
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Mothra
Znuny expert
Posts: 189
Joined: 26 Oct 2010, 15:04
Znuny Version: 3.2.11

Re: PostMaster Filter RegEx question

Post by Mothra »

crythias wrote:3 asterisks is (apparently) simply the only placeholder for the first thing that was matched above.

^\[Ticket\#([0-9]{15})\] forces checking for a 15 digit number. I wonder if it will help.
Alternatively.. (ick)
^\[Ticket\#(\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d)\]
Yes, it does, thanks for the suggestion :)

Fortunately, for my purposes, this rule only needs to be implemented while we wind down the old OTRS system, plus the ticket numbering format is fixed at (in fact) 16 digits (so I modified what you had above.

It still seems a bit limiting though, as creating a backreference from [\d]+ is perfectly legal in regex. Perhaps I should raise a bug?
OTRS 3.2.11 on Centos 6.4 with MySQL 5.0. Agents and internal customers authenticate via Active Directory.
Locked