Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

Remove unwanted text from HTML to text output

(0) ShareShare
ReportReport
Posted on by 6

Hi, 

 

i am hoping someone can help as im very new to this.

 

after using the HTML to text function, i would like to be able to remove all the URLs from the output, so that im just left with the content of the email, for example the out after running HTML to text would look like this (this is just an extract, normally there would be much more content and many more URLs):

 

Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join

for free today!

[https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe3115707564047a731c78-ff981675-fe5d1c777d6705797715-ff051671776607&d=100206&bmt=0]

[https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc2e0eab74b329d6864e1bcfd4c59bbeeb797c03b52ec0e62d069ff4a2e3f0]

[https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=87831421]

[https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campaignid=MKG_SOONTOSELL_02232024]

[pixel.app.returnpath.net/pixel.gif?r=964ce1dbf0dcef79cbad82c12fe25342701e4499]

 

all i want to see is:

 

Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join

for free today!

 

using the compose funciton i have tried to write something that would delete anything between square brackets (as the urls seem to be consistantly between them), but so far it has not worked.

 

any help would be appreciated!

 

thanks

  • Ellis Karim Profile Picture
    10,927 Super User 2025 Season 1 on at
    Re: Remove unwanted text from HTML to text output

    Hi  @random_user13 ,

     

    I think your issue has more to do with AI Builder prompt limitations.

     

    However, please confirm that the input text in the GTP action is the output of the Join action:

     

    Snag_ee875a.png

     Add a compose action to check the length of the text string being used as the prompt. 

    Snag_eec9f1.png

    Check the runtime output of the Compose 2 action:

    Snag_ef112c.png

     I don't work with AI Builder prompt, but from what I have read:

    "Unfortunately, it's not possible to augment the limit as this is a limitation from the GPT 3.5 service. What you can do is split your initial text into couple of pieces, summarize each piece and aggregate summaries (or summarize once again the aggregation of summaries)." 

     

    Hope this helps.


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

     

     

     

  • random_user13 Profile Picture
    6 on at
    Re: Remove unwanted text from HTML to text output

    Hi ellis, please see the image below:

    random_user13_0-1713108583152.png

     

    i appreciate any help you can give.

     

    Many thanks

  • Ellis Karim Profile Picture
    10,927 Super User 2025 Season 1 on at
    Re: Remove unwanted text from HTML to text output

    Hi @random_user13 ,

     

    At which action is the flow failing? The HTML to Text? If so, please post the data if possible.


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

  • random_user13 Profile Picture
    6 on at
    Re: Remove unwanted text from HTML to text output

    Hi Ellis,

     

    apologies for the very delayed response!

     

    your solution seems to have worked on a couple of the tests i ran which is great thank you. However the reason i wanted to remove all the HTML code is i kept getting the error below, which updating the flow with your edits hasnt seemed to resolved. i thought removing all the excess text would bring down the number of characters but no joy:

     

    {"operationStatus":"Error","error":{"type":"Error","code":"InvalidPredictionInput","message":"Input prompt length cannot exceed 64936 characters or 16384 tokens. Please try again with a shorter prompt","properties":{"BackendErrorCode":"InvalidInferenceInput","DependencyHttpStatusCode":"400"},"innerErrors":[{"scope":"Generic","target":null,"code":"TooManyInputTokens","type":"Error","properties":{"maxCharacters":"64936","MlIssueCode":"TooManyInputTokens"}}]},"predictionId":null}

     

    any ideas??

  • Ellis Karim Profile Picture
    10,927 Super User 2025 Season 1 on at
    Re: Remove unwanted text from HTML to text output

    Hi @random_user13 ,

     

    Here's my updated attempt using the following data I made-up using your sample data.  You will need to test it well with your actual data.

     

    My sample date from an HTML email:

     

    Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join
    for free today
    
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    Terms and conditions for the offer can be found on our website.
    
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    This is my hidden text!!!!
    
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&partner_uid=39fc]
    
    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&partner_uid=8783]
    
    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&advertiserid=100007688&campai]
    
    Happy sales!
    

     

    Split the text at each new line:

    Snag_dfd0005.png

    The filter array action will not select any blank lines, and will select items that don't begin with [http.

     

    Compose:

    split(outputs('Html_to_text')?['body'], decodeUriComponent('%0A'))

     

    Filter Array 2:

    @and(not(empty(item())), not(startsWith(item(), '[http')))

     

    The filter array action produces an array of strings:

     

    [
     "Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join",
     "for free today",
     "Terms and conditions for the offer can be found on our website.",
     "This is my hidden text!!!!",
     "Happy sales!"
    ]

     

    Note that the HTML to Text action split this text into two line:

     

    Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join
    for free today

     

    Next I'm using the join action to add the html line break element <br>  because I want to use the text in the Outlook Send an Email action:

    Snag_e02bf75.png

     

    Hope this helps.

     


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

  • random_user13 Profile Picture
    6 on at
    Re: Remove unwanted text from HTML to text output

    Hi Ellis,

     

    thanks for getting back to me.

    i need to remove any instance of text between square brackets and leave any other text, for example i want this:

     

    "Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join

    for free today!

    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756...]

    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&amp;partner_uid=39fc...]

    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&amp;partner_uid=8783...]

    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&amp;advertiserid=100007688&amp;campai...]

    Terms and conditions for the over can be found on our website

    [https://click.emails.skechers.com/open.aspx?ffcb10-fecf15727463077f-fe591d767464007f721d-fe311570756...]

    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_sha25&amp;partner_uid=39fc...]

    [https://beacon.krxd.net/1x1_usermatch.gif?partner=LprH63a7_sfmc_100007688_subid&amp;partner_uid=8783...]

    [https://beacon.krxd.net/1x1_ad_impression.gif?confid=so3yexmpm&amp;advertiserid=100007688&amp;campai...]"

     

    to end up like this:

    "Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join

    for free today!

    Terms and conditions for the over can be found on our website"

     

    thanks!

     

     

  • Ellis Karim Profile Picture
    10,927 Super User 2025 Season 1 on at
    Re: Remove unwanted text from HTML to text output

    Hi @random_user13 ,

     

    If you are confident that you only need text up to (but excluding) the first [ character, you can try the following expression as shown in the example below:

     

    Snag_a87ab8d.png

     

    We split the string at every occurrence of the [ character. 

     

    trim(first(split(variables('varText'),'[')))

     

    Split returns an array of strings and we just need to take the first one:

    Snag_a8b5dc7.png
    The trim action removes any spaces before and after the string:
    Get 20% off (almost) everything as a Skechers Plus member + free shipping. Join for free today!
     

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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow