Deleteing content from an email, after "Kind regards"

Hi,

I am working with emails and outlook activities, however, I wish to delete all of the information beyond the closing of the email at “Kind Regards” in order to not extract the footer and other irrelevant information.

How would I go about this?

An example would be like:

Hi, this order has been cancelled. Kind regards.
(followed by text I wish to delete)

You could use Regex to achieve this. Extract the string as normal and use a matches activity with your extracted string and the following expression:

“^[\s\S]*?(?>[Kk]ind [Rr]egards.)”

This returns a type IEnumerable. To return the value to type string, use an assign activity:

myString=outRegex(0).toString

1 Like

Or with a Regex.Replace

import System.Text.RegularExpressions

myString = Regex.Replace(myString, "(?<=kind\sregards)[\s\S]*", ".", RegexOptions.IgnoreCase)
2 Likes