Matches activities

Hello everyone, I want to save the body from the email received from my colleague. As you can see bellow, the email looks like this, what I want is to extract all the data and put them into excel. Now, the issue is how can I save the dates separately in excel in two different rows with “Matches” activities ( 2/2/2021 and 2/5/2021). Can anyone help me with this ?

Thank you very much!

12345678 2/2/2021 3:00:00 PM ABC1234567890 90 Customer Name Name 12345 2/5/2021 1234567-01

Hi @ovidiu_2088

Please find the regex below for extracting dates,

\d{1,2}\/\d{1,2}\/\d{2,4}

Use it as like this

System.Text.Regularexpressions.regex.matches("yourstring","yourpattern")

And for getting the matches activities output to excel please refer the below post,

Thanks

Thank you very much for fast answer but what I want is to find and save separately the dates in two different rows in excel. One date is for loading and one for delivery. The result I want to be something like :

Loading date Delivery date
2/2/2021 5/2/2021

@ovidiu_2088

Is your Email body always contains two dates ?

Unfortunately yes.

@ovidiu_2088

Try below steps.

  1. Use Build DataTable activity and provide two columns as Loading date and Delivery date. Let’s say ‘DTDates’

  2. And then use Matches activity to get Dates from Email body and it will give output as IEnumerable. Let’s say ColMatches

  3. And then use Add DataRow activity and pass and DTDates and ArrayRow as below.

                 {ColMatches(0).ToString,ColMatches(1).ToString}
    
  4. Finally use Write Range activity and pass DTDates to write into Excel file.

Something I’m not doing well.

@ovidiu_2088

It’s because you passed DTDates variable to it.

In Matches activity, pass below values.

Input: Email body
Pattern: \d{1,2}/\d{1,2}/\d{2,4}

In Add DataRow activity, pass below values.

ArrayRow: {ColMatches(0).ToString,ColMatches(1).ToString}

DataTable: DTDates

Note: No need to pass any value to DataRow field.

1 Like

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