cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jakson
Helper III
Helper III

Retrieve email messages - isolate a part of a date string

I've created an MS Form that's basically a questionnaire. Our company collects these from our employees and catalogues them for historical purposes. Basically, I need to retrieve these emailed Forms responses per person, per month.

 

Example:

John Deer's responses.10-29-2021.PDF

 

Any idea how to isolate the month value of the date string? I can determine the person it belongs to by email address.

 

Desired result:

John Deer's responses.10-29-2021.PDF

 

In effect I just need to trim out all the data but the date value. I've done some string manipulation in the past but that's only with VBA.

 

Guidance is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
AgniusBartninka
Advocate III
Advocate III

Use the Parse Text action with some Regular Expressions (RegEx).

Here's a sample code from PAD on how to get what you want, assuming the text is stored in %Text% (you can paste this directly into your PAD):

Text.ParseText.RegexParseForFirstOccurrence Text: Text TextToFind: $'''\\d{2}(?=-\\d{2}-)''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Match

  You will then end up with the value you want in %Match%:

AgniusBartninka_0-1635667034316.png

 

The idea behind the RegEx above is as follows:

\d - this indicates a digit

{n} - this indicates the quantity of the item before this, meaning that \d{2} indicates 2 digits. You can also use \d\d instead, if you prefer.

(?={something}) is a so-called "positive lookahead". It basically is a part of the pattern that must follow whatever you're looking for, but is not included in the result. So, (?=-\d{2}-) means that your pattern must be followed by a dash (-), two digits and another dash.

 

So basically, the entire pattern \d{2}(?=-\d{2}-) will retrieve any two digits that are followed by a dash, two more digits and another dash.

In all cases of a date in the format of DD-MM-YYYY, you will get the DD part of it.

Also, it will completely ignore everything before the two digits.

 

If you find this helpful, please mark it as the preferred solution.

If you have any further questions to how this works, let me know.

 

View solution in original post

2 REPLIES 2
VJR
Memorable Member
Memorable Member

Hi @Jakson 

 

Here is how the entire flow looks like

VJR_0-1635655585595.png

 

The first Display Message on Line No 2 will get the date part from the text

VJR_1-1635655668046.png

 

The last Display Message will give the name of the month.

If you want the full month name then use MMMM in the formatting.

 

VJR_2-1635655761484.png

 

 

Copy and paste the below code into a new PAD flow and you can make modifications for yourself.

 

Text.SplitWithDelimiter Text: $'''John Deer\'s responses.10-29-2021.PDF''' CustomDelimiter: $'''.''' IsRegEx: False Result=> TextList
Display.ShowMessage Message: TextList[1] Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
Text.ToDateTimeCustomFormat Text: TextList[1] CustomFormat: $'''MM-dd-yyyy''' DateTime=> TextAsDateTime
Display.ShowMessage Message: TextAsDateTime Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
Text.FromCustomDateTime DateTime: TextAsDateTime CustomFormat: $'''MMM''' Result=> FormattedDateTime
Display.ShowMessage Message: FormattedDateTime Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
AgniusBartninka
Advocate III
Advocate III

Use the Parse Text action with some Regular Expressions (RegEx).

Here's a sample code from PAD on how to get what you want, assuming the text is stored in %Text% (you can paste this directly into your PAD):

Text.ParseText.RegexParseForFirstOccurrence Text: Text TextToFind: $'''\\d{2}(?=-\\d{2}-)''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Match

  You will then end up with the value you want in %Match%:

AgniusBartninka_0-1635667034316.png

 

The idea behind the RegEx above is as follows:

\d - this indicates a digit

{n} - this indicates the quantity of the item before this, meaning that \d{2} indicates 2 digits. You can also use \d\d instead, if you prefer.

(?={something}) is a so-called "positive lookahead". It basically is a part of the pattern that must follow whatever you're looking for, but is not included in the result. So, (?=-\d{2}-) means that your pattern must be followed by a dash (-), two digits and another dash.

 

So basically, the entire pattern \d{2}(?=-\d{2}-) will retrieve any two digits that are followed by a dash, two more digits and another dash.

In all cases of a date in the format of DD-MM-YYYY, you will get the DD part of it.

Also, it will completely ignore everything before the two digits.

 

If you find this helpful, please mark it as the preferred solution.

If you have any further questions to how this works, let me know.

 

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Kudoed Authors
Users online (3,261)