[rt-users] Scrip check body of email for text

Gene LeDuc gleduc at mail.sdsu.edu
Mon Nov 16 11:56:43 EST 2009


Hi Kevin,

Check out the /m modifier.  This should match what you are specifying 
(which is different from your example, by the way):
   $Transaction->Content =~ /^RMA.*has been received$/m

The /m tells perl to treat the string as multiple lines and the ^$ 
anchors match the beginning and end of any line in the string.

Your specification (and my suggestion) does not match your example 
because the example line ends with " " rather than "d".  If you want 
trailing spaces to be Ok in the line, use "received\s*$" instead of 
"received$".  A line that ends with "received." will not match, though.

If all you want is "RMA" at the beginning and followed by "has been 
received" somewhere on the same line, then you could use "received.*$" 
instead.  That would allow anything to follow "received" and still 
match.  Have fun!

Regards,
Gene

Kevin Squire wrote:
> I am modifying the scrip found at 
> http://www.gossamer-threads.com/lists/rt/users/70038#70038
> posted by gleduc at -----  and could use some help
> 
> 
> The original, "true if e-mail contains 'ok'"
>    && $Transaction->Content =~ /\bok\s/i; 
> 
> I need to make it true IF a line (any line - 1st, 2nd, etc) starts with
> "RMA" and ends with "has been received"
> 
> An example line is:
> "RMA-47767-1 has been received "
> 
> (This email is coming in from a third party, that I do NOT have much
> control over their setup... so there may or may not be a space at the
> end of the line, and I can't not control if it is the 1st line or not -
> it always appears as the first line of TEXT .. but I am pretty sure
> their system is adding a extra blank line or two at the beginning of
> the body)
> 
> 




More information about the rt-users mailing list