cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kerrykevin
Helper I
Helper I

split string to get a string between two charecters

Hello,

 

I want to split/trim this string:

"Updates": "<div class=\"External995924590B60\">xyz</div>",

 

such that i get: xyz

 

I have tried this: last(split(first(split(outputs('Get_item')?['body/Updates'],'\">')),'</div>",'))

 

But ain't getting the desired string xyz.

 

Please help!

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

Initialize 2 variables

  • Variable IndexOfValue

 

 

indexOf(variables('Updates'),'</div>')

 

 

Variable LastIndexOfValue

 

 

lastIndexOf(variables('Updates'),'\">')

 

 

If this is flow then here is the formula

 

 

 

substring(variables('Updates'),add(lastIndexOf(variables('Updates'),'\">'),3),sub(sub(variables('IndexOfValue'),variables('LastIndexOfValue')),3))

 

 

 

  • Using 2 variables to get the index and view it (We can make it all in one formula if needed)
  • 3 means length of ('\">') which is required

 

StalinPonnusamy_0-1627221442099.png

 

View solution in original post

3 REPLIES 3
WarrenBelz
Super User III
Super User III

@kerrykevin ,

Assuming the source syntax is consistent - if this is from a Flow, the syntax below is wrong (this is assuming Power Apps code)

 

With(
   {
      wFirst: 
      Last(
         FirstN(
            Split(
               outputs('Get_item')?['body/Updates'],
               ">"
            ),
            2
         )
      ).Result
   },
   Left(
      wFirst,
      Find(
         "<",
         wFirst
      ) - 1
   )
)

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

StalinPonnusamy
Community Champion
Community Champion

Initialize 2 variables

  • Variable IndexOfValue

 

 

indexOf(variables('Updates'),'</div>')

 

 

Variable LastIndexOfValue

 

 

lastIndexOf(variables('Updates'),'\">')

 

 

If this is flow then here is the formula

 

 

 

substring(variables('Updates'),add(lastIndexOf(variables('Updates'),'\">'),3),sub(sub(variables('IndexOfValue'),variables('LastIndexOfValue')),3))

 

 

 

  • Using 2 variables to get the index and view it (We can make it all in one formula if needed)
  • 3 means length of ('\">') which is required

 

StalinPonnusamy_0-1627221442099.png

 

View solution in original post

kerrykevin
Helper I
Helper I

Hi,

 

Thank you for your replies.

 

I eventually got the solution.

 

I used:

trim(first(split(last(split(outputs('Get_item')?['body/Updates'],'">')),'</div>')))

 

Thanks again.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,332)