cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
isobelcoyle
Level: Power Up

Expression needed to get a string from inbetween two other strings

I need an expression to get a string from in-between two others. Essentially I need it to say, get the string that is after A, but before B. 

 

The closest thing I could find is to use substring ('somevalue-abc-somevalue',10,3) however this won't work as the string I want to retain will change every time the flow runs, so I cant specify what it will be or how many characters it will have.  

 

There seems to be little resources to help with workflow definition language other than this https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

 

More information!!

I am trying to grab an email address from html text of an email body. So the text i am using will be like the following 

 

 From:</span></b><span lang="EN-US"> Firstname Lastname [mailto:e.xample@emailhost.com]
<br>
<b>Sent:</b> 31 January 2018 16:30<br>

 

The information I need is in bold, i was hoping there would be a way to say take the string inbetween "EN-US"> and <br><b>Sent:

 

Or somthing similar!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Expression needed to get a string from inbetween two other strings

You can use the split function, which will break down the string based on a separator (in your case, '-') into an array. Later you can check whether the initial value had indeed 3 parts (or at least 2), and if that's the case, you can take the second value of the array (the first index is 0).

ForumPost001.png

d

5 REPLIES 5
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Expression needed to get a string from inbetween two other strings

You can use the split function, which will break down the string based on a separator (in your case, '-') into an array. Later you can check whether the initial value had indeed 3 parts (or at least 2), and if that's the case, you can take the second value of the array (the first index is 0).

ForumPost001.png

d

Super User
Super User

Re: Expression needed to get a string from inbetween two other strings

Hi @isobelcoyle,

I understand you to mean that your text value doesn't have separators (like -), but rather there is always some specific word A and some word B, and you need to retrieve the text that happens to fall between A and B. Is that right?

If so, then perhaps a combination of the indexOf and substring functions would help. That is, if you use indexOf to find the position of the end of word A and also to find the position of the beginning of word B, then I think you could use substring with those two indexOf values, to find your result.

I didn't test this, but I think it should work.

If not, let me know, and I'll puzzle it out - I don't have time at the moment, but I could look at it more tomorrow :-)

 

Sandy

 

PS - I just realized I was looking at the LogicApps reference because you mentioned it, and because Carlos was showing this in a Flow - but are you actually needing to do this in a PowerApp? It may  be similar, but different - I'd need to test.



Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


isobelcoyle
Level: Power Up

Re: Expression needed to get a string from inbetween two other strings

Hi Sandy 

 

Thank you for your comment.The text value will have separators, sorry I did not mention that!

 

I am trying to grab an email address from html text of an email body. So the text i am using will be like the following 

 

 From:</span></b><span lang="EN-US"> Firstname Lastname [mailto:e.xample@emailhost.com]
<br>
<b>Sent:</b> 31 January 2018 16:30<br>

 

The information I need is in bold, i was hoping there would be a way to say take the string inbetween "EN-US"> and <br><b>Sent:

 

Or somthing similar!!

 

I hope this information helps

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Expression needed to get a string from inbetween two other strings

Hi @isobelcoyle, can you confirm whether you are trying to get this expression in PowerApps or in Flow? The link you had on your original post is for the flow definition language. Depending on that we can point you to the right direction.

isobelcoyle
Level: Power Up

Re: Expression needed to get a string from inbetween two other strings

Hi Carlos, this is in Flow!