Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Split and Clean String to Extract Value

Posted on by
Hi Everyone, 
 
I have an E-Mail Body that looks like this:

E-Mail:
---------------------------------------
Dear,
 
text text  text text text 
 
text text text text: 
•    irrelevant text 15.11.2024                    
•    irrelevant text 19.11.2024    
•    irrelevant text 21.11.2024 
------------------------------------------

I want to extract only extracts the dates in red and save each one in different compose to use it later. I do not want to split based on the bullet points "•" as it might change in the future. What I achieved so far is the following array:

[
  " 15.11.2024                   ",
  "·             irrelevanttext 19.11.2024   ",
  "·             irrelevanttext 21.11.2024"
]

I split after the first irrlevant text starts an ignore the rest of the e-mail. The problem is that I have spaces after and before each string. and I also have the bulletpoint "·" at the beginning of the string. How can clean each one so I only have dates and store them in different compose? 

thanks in advance!
 
  • AlexEncodian Profile Picture
    AlexEncodian 4,261 on at
    Split and Clean String to Extract Value
    Encodian's Utility - Search Text (Regex) allows you to do a regex search on your email.
     
    The following regex query will identify the dates:
     
    \d{2}\.\d{2}\.\d{4}
     
     
    Output:
     
  • Chriddle Profile Picture
    Chriddle 7,086 on at
    Split and Clean String to Extract Value
    The idea is to split your text at <space>. Before that, replace characters like line breaks (or other characters that might be next to your dates) with spaces.
    Then filter for items that resemble a date.
    Example: length is equal to 10, the third and fifth characters are periods, the first 2 characters are numbers etc.
     
     
    From
    split(
    	replace(
    		outputs('Compose'),
    		decodeUriComponent('%0A'),
    		' '
    	),
    	' '
    )
    Filter (advanced mode)
    @and(
    	equals(length(item()), 10),
    	equals(substring(item(), 2, 1), '.'),
    	equals(substring(item(), 5, 1), '.'),
    	isInt(substring(item(), 0, 2)),
    	isInt(substring(item(), 3, 2)),
    	isInt(substring(item(), 6, 4))
    )
     

  • VictorIvanidze Profile Picture
    VictorIvanidze 11,840 on at
    Split and Clean String to Extract Value
    Split by '.2024' and parse each string in the resulting array. Note that the flow will stop worling in 2025.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard