我正在使用SendGrid的电子邮件解析器将电子邮件正文返回到我的应用程序。问题是,如果该消息是答复,则它还会返回原始消息以及该答复消息。我想做的是解析原始消息中的回复。为此,我认为我需要找到每个主要电子邮件客户端在回复和原始邮件之间使用的文本/字符,并删除原始邮件。
我想做的是使用ColdFusion查看以下示例文本,并删除以下文本中 2019年9月13日星期五右边的所有内容。这是一个Gmail回复示例。
"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! "
在CF中怎么可能?如果您知道实现此目的的更好方法,那也很好。
所以我要返回的文本将是:
"here's a test reply with multiple line breaks"
---更新#1 ---
这是我到目前为止所拥有的。查找关键字短语是否包含在主体中似乎很有效。我该如何使用left()函数在比赛之前获取内容?
<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>
答案 0 :(得分:0)
我能够使用以下方法完成我需要做的事情:
<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">
<cfset findphrase = reFindNoCase(regEx, myString ,1,false,"one")>
<cfif findphrase>
Found it
<cfelse>
No Match
</cfif>
<br />
<cfoutput>
Position: #findphrase#<br /><br />
Reply: #Left(myString, findphrase-1)#
</cfoutput>