web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Substring extract data with add and sub, how to handle last unknown lines

(0) ShareShare
ReportReport
Posted on by 26

Hello community!

 

I am trying to extract data from a email.

I use the HTML to TEXT conversion

 

The text is like this:

 

 

Some non relevant start info (dynamic in length)

Serial number: 180806168
Version: DF900 1.2.2
Modifications: 1 (0x0001)
Action: Modification

Some non relevant end text bla bla (dynamic as well)

 

 

I use the following COMPOSE to extract the data 

For example serial number. This works ok!

 

 

trim(
	substring(
		body('Html_to_text'),
		add(
			indexOf(
				body('Html_to_text'),
				'Serial Number: '
				),
			14),
			sub(
				indexOf(
					body('Html_to_text'),
					'Version: '),
		add(
			indexOf(
				body('Html_to_text'),
				'Serial Number: '
				 ),
			14)
		)
	)
)

 

This will work for all but the last entry called ACTION:

I cannot count the characters because

 

  1. ACTION could be dynamic (but will be always 1 word, like REBOOT or SHUTDOWN)
  2. There is always non relevant text in the end.

Breaking my head over this, the only thing I can come up with is find the text until the next space or CRLF..

 

Or is it possible to declare the rest of the text without knowing what it will be....

 

Kind regards,

 

John 

 

I have the same question (0)
  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at
    Re: Substring extract data with add and sub, how to handle last unknown lines

    @jbruijntjes 

    Hey there.  Maybe consider the split() function instead.  You could split everything on the ': ' and grab the array elements you want, and then split again on the carriage return ('\n' maybe??).  Here's a quick video I did on normal strings like eMails, but could probably be applied to this.  Then, it wouldn't matter what the header/keys were called...just where they were placed.

     

    Keep us posted.

    -Ed

     

     

    If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard