Jump to content

Helpdesk Email Regex Help


plzmakehelpregards

Recommended Posts

Hi,

 

I manage a PHP based support helpdesk; when staff reply to a ticket via the web interface, it sends the response in the form of an email to the customer. To respond, the customer can simply reply directly to the email and their response is automatically piped into the helpdesk and posted to the corresponding ticket via a mail parser function. The problem is that often customers keep the staff response intact in the bottom of the email; so it looks something like this:

 

=============================================

thanks for the help bob, I'll try your recommendation.

-Tom Fakeman

On Tuesday, April 1, 2014 at 2:00 AM, Fake Support Company.com wrote:

> Please try shooting the device multiple times with any available firearm; if that doesn't work please let us know.... Either

> way at least you will probably feel better :)

>
> Bob F.
> Senior Technician
> Fake Support Company.com

=============================================

 

Thus, when you email is parsed, everything is posted to the ticket, including "On Tuesday, April 1, 2014 at 2:00 AM, Fake Support Company.com wrote:" and everything under it..... Ideally only the following portion would be posted to the ticket:

 

=============================================

thanks for the help bob, I'll try your recommendation.

-Tom Fakeman

=============================================

 

With that said, the helpdesk does include a feature that allows me to specify a "breakline" regex specifically to take care of this, thus basically I need help constructing a regex string to match the "On Tuesday, April 1, 2014 at 2:00 AM, Fake Support Company.com wrote:" string; I have very little PHP development experience but I could probably stumble my way through making a fairly basic regex, however I'm afraid if its too basic it will match other lines and I will run into issues with false-positive breaklines.

 

If someone could assist me in creating an appropriate regex for this I'd greatly appreciate it.

 

EDIT: I'm not looking to freeload in anyway and thus I'll be more than happy to send a donation to whomever can get me a working regex and/or the phpfreaks.com site (via http://www.phpfreaks.com/page/donations ).

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/288492-helpdesk-email-regex-help/
Share on other sites

The intro line won't always be in that format - different email clients and especially different (native) language clients may do it differently. Fortunately the > prefix is pretty standard so I would go about it as finding a line that doesn't start with a > then maybe blank lines then lines starting with >.

 

Couple expressions to try, which one works depends on the way the regex is being executed:

^[^>].*\s+>.*\s+>
[\r\n]+[^>][^\r\n]+[\r\n]+>[^\r\n]+[\r\n]+>
If neither work then it'd help to get specifics about what software you're using and ideally some documentation about what it supports for regular expressions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.