cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ssp_power
Regular Visitor

Find text position returns -1

Ssp_power_0-1645798114398.png

 

Please refer to the embedded screenshot. I have tried to get offset of string "type=" in the message and it returns -1. What is wrong here ? What should be done to get the correct offset ?

1 ACCEPTED SOLUTION

Accepted Solutions

Will type and title only contain single words such as:

type=story title=abcde

 

Or Will type and title contain multiple words such as:

type=non fiction title=Travel to Mars

 

Do you want to extracts both type and title? To extract type and title - when they are single words only - you can use the following expressions:

 

Type:
trim(first(split(last(split(variables('varText'),'type=')), 'title=')))

Title:
Last(split(variables('varText'),'='))

Snag_cb1a9e1.png

 

Snag_cb292ba.png

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

 

 

 

View solution in original post

4 REPLIES 4
ekarim2020
Super User
Super User

Do you mean that you want to extract the substring string 'story' from the string 'create type=story title=abcde'?

 

Ellis

Hi Ellis,

I realized that I had flipped "Text" and "Search Text" and hence I was getting -1 as the offset. I swapped these and I got it. Now based on your reply, am curious, how do I parse the key value parameters ? 

Will type and title only contain single words such as:

type=story title=abcde

 

Or Will type and title contain multiple words such as:

type=non fiction title=Travel to Mars

 

Do you want to extracts both type and title? To extract type and title - when they are single words only - you can use the following expressions:

 

Type:
trim(first(split(last(split(variables('varText'),'type=')), 'title=')))

Title:
Last(split(variables('varText'),'='))

Snag_cb1a9e1.png

 

Snag_cb292ba.png

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

 

 

 

Ssp_power
Regular Visitor

Thanks Ellis. Yes, the values would be phrases (not just words). I will take it from here. 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,867)