Extracting Text From Email Body (After Keyword) - Multi Line

Hi there,

I’m currently having issues extracting multi-line text from an email body, after a key word (including that key word).

E.g, my email looks like so:

Client No: 1234

Client Name: Mr Smith

Client Response: ---------

Hello Mr A,
Please find your info below

Many thanks,
Mr Smith

How would I be able to extract everything from “Client Response:” to the very end of the email using regex? I have already used an assign activity to get my email body into a string variable (named MailMessageBody), but aren’t sure how best to use regex to pull info across multiple lines.

Thanks in advance!

Hi @sam.willson

Use the for each and pass the currentmail.body and save that in a variable.

use the regex as below:

((Client Response[\s\S]*))
System.Text.RegularExpressions.Regex.Match(Variable,"((Client Response[\s\S]*))").Value

Regards

Hi @sam.willson

Please try this

(?=Client Response:).*[\s\S]*

System.Text.RegularExpressions.Regex.Match(Input,"(?=Client Response:).*[\s\S]*").Value

Regards,

Hi @sam.willson

You can use the below regex
image

Hope it helps!!

@sam.willson

If that is the need then you dont need a regex also…

You can use str.Split({"Client Response:"},StringSplitOptions.None).Last

Cheers

1 Like

Thank you for this, that’s worked perfectly! Appreciate the really quick response :grinning:

1 Like

@sam.willson

Please mark the appropriate post as solution

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.