Description:
When trying to use wild card characters such as an asterisk '*' to represent a match on any character, they do not seem to match was expected.
If I use the same search string when searching tickets, in SQL or in a BOXI report it pulls back results, but does not work when sending in an email to Service Desk. It does not match up to the rule as expected.
For example, using the following as a Filter String:
*Incident*Create
does not match when emails are sent in with subject lines like the following:
FW: Incident_Create
RE:IncidentCreate
Incident-Create
Incident Create
Solution:
The Filter String on Mailbox Rules uses "regex" which is a language used to match string patterns:
http://en.wikipedia.org/wiki/Regular_expression
For example an asterisk will perform a match on 0 or more of the preceding characters.
In this case, the following regex when used as a Filter String on the mailbox rule would find a match.
[ \r\n\t]*incident[_- ]*create[_- ]*[ \r\n\t]*
should match these patterns:
FW: Incident_Create
RE:IncidentCreate
Incident-Create
Incident Create
Here are some commonly used regex characters:
? The question mark indicates there is zero or one of the preceding element. For example, colou?r matches both "color" and "colour".
* The asterisk indicates there is zero or more of the preceding element. For example, ab*c matches "ac", "abc", "abbc", "abbbc", and so on.
+ The plus sign indicates there is one or more of the preceding element. For example, ab+c matches "abc", "abbc", "abbbc", and so on, but not "ac".
[ ] A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c". [a-z] specifies a
range which matches any lowercase letter from "a" to "z". These forms can be mixed: [abcx-z] matches "a", "b", "c", "x", "y", or "z", as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^) character within the brackets: [abc-], [-abc]. Note that
backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].
[ \t\r\n\v\f] Whitespace characters
A helpful web site for testing regex patterns is: http://regexpal.com/
This can be used to test your regex before using it in a Mailbox rule, as shown in Figure 1.
Figure 1:
<Please see attached file for image>
To troubleshoot regex matching with the Service Desk Email interface, you may use the following command on the primary server:
pdm_logstat -n pdm_maileater_nxd TRACE
This will product logging to the stdlogs displaying how it used the regex filter strings and what mailbox rule was used as a result.
For example:
10/01 17:44:54.23 usvd127 pdm_maileater_nxd 4628 MILESTONE pdm_maileater_nxd.c 9766 Parsing Email From ([email protected]) Subject (mensaje_de_correo) 10/01 17:44:54.23 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 4588 No Attachment Repository associated with Mailbox. 10/01 17:44:54.23 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 9937 Processing Email From([email protected]) Subject(mensaje_de_correo) Body(%description=test ) ... 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6396 Checking message subject for filter pattern "[ \t\r\n]*mensaje de correo*[ \t\r\n]". 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10814 Regex is not processing backslashes as escapes. Must mutate. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10823 Performing mass mutuation with global substitution. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10918 Before backslash mutation: [ \t\r\n]*mensaje de correo*[ \t\r\n] 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10919 After backslash mutation: [ ]*mensaje de correo*[ ] 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6552 Checking for filter keyphrase match Anywhere In Field... 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6919 Filter match Not Found. Passing to next Filter. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6396 Checking message subject for filter pattern "[ \t\r\n]*mensaje_de_correo*[ \t\r\n] ". 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10814 Regex is not processing backslashes as escapes. Must mutate. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10823 Performing mass mutuation with global substitution. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10918 Before backslash mutation: [ \t\r\n]*mensaje_de_correo*[ \t\r\n] 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 10919 After backslash mutation: [ ]*mensaje_de_correo*[ ] 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6552 Checking for filter keyphrase match Anywhere In Field... 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 6924 Filter match Not Found. This is the last Filter. Message will not be applied. 10/01 17:44:54.24 usvd127 pdm_maileater_nxd 4628 TRACE pdm_maileater_nxd.c 8682 DELETE command sent to POP server.
To Disable the logging, please run:
pdm_logstat -n pdm_maileater_nxd