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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Removing Text from a s...
Power Automate
Answered

Removing Text from a string

(1) ShareShare
ReportReport
Posted on by 50

Hello

I have flow that will extract an HTML table from email body and switch it to a text.

i need to remove certain words from the string. Please see attached photo I'm trying to remove "ThisIsName" from the string and keep the U123456. I removed the spaces from the string using Replace expression. and i was able remove Comments  however name can vary so sometimes it can include 5,7,8 ... etc characters how can i remove the name and and keep the U123456?

Categories:
I have the same question (0)
  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @husham86  Pls share attached photo. Seems it is missing.

    Please 'Thumbs Up' the posts that helped you and 'Accept as Solution' if my post answered your question.

    @Hardesh /Gopenly.in

  • husham86 Profile Picture
    50 on at

    Remove name.png

  • husham86 Profile Picture
    50 on at

    Sorry i forgot add it

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @husham86 

    Is all you want to keep U123456?  If so, will that always be the same length (7 characters)?

    Is U123456 always at the end?

    If the answer to all questions is yes, , then you can use this expression:  slice(your text here, -7)

     

     

     

     

     

     

  • David- Profile Picture
    1,254 on at

    I do not profess to be an expert in this. I saw you problem and it intrigued me, and as I see how this could be useful. So, I tested how I would go about this. It uses an assumption that the string you want (U#######) is always at the end of the e-mail and nothing else follows. In addition, it assumes your number is always proceeded by a capital letter U. If that is not the case, this will not work, but it may give you an idea on how to approach the problem.

     

    If this is what you need, the following seems to work:

    David_0-1660846426303.png

    • For testing, I am manually triggering the workflow so I can enter various versions of your output above to make sure it works.
    • The first compose action searches for the last uppercase U in the output to return its position (index). The expression used:

     

    lastIndexOf(triggerBody()['text'],'U')​

     

    • The next compose then extracts the text from the last U until the end. The expression used:

     

    substring(triggerBody()['text'], int(outputs('Compose')),sub(length(triggerBody()['text']),int(outputs('Compose'))))​

     

    You would of course replace triggerBody()['text'] the appropriate dynamic content from your flow.
     
    This is an example of the result:
    David_1-1660846819968.png

     

  • David- Profile Picture
    1,254 on at

    That's even easier than what I was attempting. So slice takes content from the end of a string? Although, I believe in the original post, @husham86  said the length could vary (at least I was assuming he was referring to the what he needs to extract and not "ThisIsName". 

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @David- 

    the slice expression can return a set number of characters for the start, end or middle of a string.  Here is a link to the documentation.

    I read the original post to say that the name can vary - I am hoping the the ID he wants to extract will not vary in length and is at the end.

     

  • husham86 Profile Picture
    50 on at

    Hello

    Thanks for your replies. the name can vary and the UXXXXX isn't at the end of the email. I tried to use 

    substring(outputs('Searching_for_Employee_Number'),indexof(outputs('Searching_for_Employee_Number'),'U')) but if the name has the letter u in their name the flow will pick that letter ("see below" urst is part of the name) and i only need the UXXXXXX

    husham86_0-1660852643219.png

     

    Thanks

  • Verified answer
    v-liwei-msft Profile Picture
    Microsoft Employee on at

    Hi @husham86 ,

     

    Could you please tell me:

    Is your email formatted like this? 

    Comments
    Name888
    U7283271
    XXXXXXX
    XXXXXXX

    1. Use replace to replace "Comments" with a null character. 

    2. Use trim to remove spaces in the returned string. 

    3. Use split to split the string into arrays with newline as delimiter. 

    4. Add [1] after the expression.

    I have made a test for your reference:

    vliweimsft_0-1661225695570.jpeg

    vliweimsft_1-1661225706695.png

    split(trim(replace(outputs('Compose'),'Comments','')),decodeUriComponent('%0A'))[1]

     

    Best Regards,

    Levi

  • husham86 Profile Picture
    50 on at

    WOW that worked!!! Thank You very much @v-liwei-msft  

    I'm new to Power automate is the decodeuricomponent created a new line as delimiter ?

    Thanks

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 604

#2
Valantis Profile Picture

Valantis 502

#3
Vish WR Profile Picture

Vish WR 417

Last 30 days Overall leaderboard