I'm using SendGrid's email parser to return the body of an email to my application. The problem is, if the message is a reply it also returns the original message with the reply message. What I'm trying to do is parse out the reply from the original message. To do this I think I need to find the text/characters that each major email client uses between the reply and the original message and remove the original message.
What I'm trying to do is use ColdFusion to look at the following example text and delete out everything to the right of and including the On Fri, Sep 13, 2019 in the following text.This is an example of a gmail reply.
"here's a test reply with multiple line breaks
On Fri, Sep 13, 2019 at 5:56 PM <matt@email.com> wrote:
> ---*PLEASE REPLY ABOVE THIS LINE*---
> > This is your confirmation text
> I wonder how to keep the line breaks?
> > > Thank you! "
How would this be possible in CF? If you know of any better way to accomplish this, that would be great as well.
So the text I'd like to end up returning would be:
"here's a test reply with multiple line breaks"
--- Update #1 ---
Here's what I have so far. It seems to be working well to find if the keyword phrase is included in the body. How would I use the left() function with this to get the content before the match?
<cfset keyword = "this is ___ my keyword 33> phrase">
<cfset myString = "The dog sniffed at the this is ___ my keyword 33> phrase star fish On Sun, Sep 15, 2019 at and growled">
<cfset regEx = "\b"& keyword &"\b">
<cfif reFindNoCase(regEx, myString)> Found it <cfelse> No Match </cfif>