Regular expressions to extract information from table in email

I have an automation that opens emails I receive daily, the emails will have a table that is structured the same for every email. I have to get certain items from the table in the email. I’m able to get all the information in a string, I just need to get a regular express to get the information in bold in the below table. Can I get some guidance and some regular expressions that would extract the data written in bold below? I also posted a picture of what the table from the email looks like.


Thank you

Opportunity: CLMS – Natron Publications
Account: Brady 101
Contract Months : 42
Subscription Term : Man
Closed Date : 7/7/2023
Total Contract Value : $45
Owner : Kirk Cousins
Billing Term :
Billing Contact Name 1 : Aron Rogers
Billing Contact Email 1 : nothing@yahoo.com

Billing Contact Name 2 : Patrick Mahomes
Billing Contact Email 2 :
Email for Invoices : hello at yahoo.com
Billing Mailing Address : 900 Half way house
Client PO Number :

Hi @NATHAN_MORA
Opportunity: (.+)
Account: (.+)
Contract Months : (\d+)
Subscription Term : (\w+)
Closed Date : (\d{1,2}/\d{1,2}/\d{4})
Total Contract Value : $(\d+)
Owner : (.+)
Billing Contact Name 1 : (.+)
Billing Contact Email 1 : (.+)
Billing Contact Name 2 : (.+)
Billing Contact Email 2 : (.+)
Email for Invoices : (.+)
Billing Mailing Address : (.+)
Client PO Number : (.+)

Hope it helps!!

Hi @NATHAN_MORA

Use the below regex expressions to extract the required information from about string

Opportunity (CLMS – Natron Publications) -> (?<=Opportunity:\s).*
Contract Months (42) -> (?<=Contract Months\s:\s)\d+
Total Contract Value  ($45) -> (?<=Total Contract Value\s:\s).\d+
Owner (Kirk Cousins) -> (?<=Owner\s:\s).*
Billing Contact Email 1 (nothing@yahoo.com) -> (?<=Billing Contact Email 1\s:\s)\w*\@yahoo*\.com
Billing Mailing Address  (900 Half way house) -> (?<=Billing Mailing Address\s:\s).*

Hope it helps!!

1. Extracting CLMS - Natron Publications:
  * Regex: `(?<=Opportunity:\s).*`
  * Result: CLMS - Natron Publications
2. Extracting Account: Brady 101:
  * Regex: `(?<=Account:\s).*`
  * Result: Brady 101
3. Extracting Contract Months: 42:
  * Regex: `(?<=Contract Months : \s).*`
  * Result: 42
4. Extracting Subscription Term: Man:
  * Regex: `(?<=Subscription Term : \s).*`
  * Result: Man
1. Extracting Closed Date: 7/7/2023:
  * Regex: `(?<=Closed Date : \s).*`
  * Result: 7/7/2023
2. Extracting Total Contract Value: $45:
  * Regex: `(?<=Total Contract Value : \$).*`
  * Result: 45
3. Extracting Owner: Kirk Cousins:
  * Regex: `(?<=Owner : \s).*`
  * Result: Kirk Cousins
4. Extracting Billing Contact Name 1: Aron Rogers:
1. Extracting Billing Contact Email 1: [nothing@yahoo.com](mailto:nothing@yahoo.com):
  * Regex: `(?<=Billing Contact Email 1 : \s).*`
  * Result: [nothing@yahoo.com](mailto:nothing@yahoo.com)
2. Extracting Billing Contact Name 2: Patrick Mahomes:
  * Regex: `(?<=Billing Contact Name 2 : \s).*`
  * Result: Patrick Mahomes
3. Extracting Billing Contact Email 2:
  * Regex: `(?<=Billing Contact Email 2 : \s).*`
  * Result: (empty string)
1. Extracting Email for Invoices: hello at yahoo.com:
  * Regex: `(?<=Email for Invoices : \s).*`
  * Result: hello at yahoo.com
2. Extracting Billing Mailing Address: 900 Half way house:
  * Regex: `(?<=Billing Mailing Address : \s).*`
  * Result: 900 Half way house
3. Extracting Client PO Number:
  * Regex: `(?<=Client PO Number : \s).*`
  * Result: (empty string)```

How would Use this in studio with activities, can you send sample workflow for the regular expressions?

@NATHAN_MORA

Use the below regular expression

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“(give regex expression here)”)

Give the string input in the above expression and give the regex expression
Store the regex expressions in a list of string and use for each loop to iterate the list and store the each regex expression in a variable and pass to the above expression.

Or

Use the matches activity.
image

Hope it helps!!

If the content extracted from the Body field is of text type, then a possible answer is the one below:
GetInformation.xaml goes through the text line by line. It analyzes only the lines that contain the “:” character and those that are stated in Switch (that is, the necessary ones). The part to the right of the “:” character is extracted from each required line and will be saved in txtOutput. Then the data here can be used as desired.
We have the scheme:

txtBody= (the text in the Body field)

…….

Call Procedure GetInformation

IN: txtBody (type String)

OUT: txtOutput (type String)

……

txtOutput → (we will use the data here as we wish)


GetInformation.xaml (19.9 KB)