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 / How to remove some tex...
Power Automate
Unanswered

How to remove some text from a variable with a fixed format, but a differance value? Regular Expression?

(0) ShareShare
ReportReport
Posted on by 60

I get the html from a webpage and put it in a variable. I would like to remove some piece of text from this variable but it has a fixed format, but a difference value. Maybe with an replace action with a regular expression?

 

See 2 examples below:

 

const token = 'CfDJ8OrUC3DsyKZIhOQxh1idLV9wBJoGSwvkPZoiB2ItoPEdAqIxvD8K9nsyQ0epSLR5FFw3FEu-lCxaNapQuShNu7adPqU8r4EZ5e-ECS2uXCfZEvCWHQxnlzQ6_AazsBtiLlOFubK8bpx72PW1n80SmwS4u12RD97--rkmK9uSRoinLadgUKZYWGHDv_Y_vUfX2Q';

 

const token = 'CfDJ8OrUC3DsyKZIhOQxh1idLV_XdK8hGQ9U2aCK61qKciKz4XC-ridoR5AF4BQSC4zbGc2ABuVis7buEp-OBNFxaZJ3KRq5Fp9Ra3RAHgTCyOGqvkqnkF4eq-kJj0bC_yms3ou7Fidj0Mk5sKunKc2VjM7RV9nio5qpLzeakKBNM4VV0YV1sj9_TzryTMhpTLzAyA';

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @khhaj 

    Indeed, you're correct. You can achieve that by utilizing the Replace action. Simply specify what you want to remove directly within your source text using the replace action.

     

    Additionally, as you mentioned, we can also utilize regular expressions for this purpose.

    Deenuji_0-1709653446801.png

    In case if you require any further help, Please let me know.

     

    ----------------------------------------------------------------------------------------------------------------------------

    If I've resolved your query, please consider accepting it as the solution and giving it a thumbs up to help others find answers faster.

     

     

     

  • HAKHBIZ Profile Picture
    60 on at

    @Deenuji I would like to remove this whole text. Do you know which regular expression?

     

    Before variable text:

     

    <div>some html</div>

     

    const token = 'CfDJ8OrUC3DsyKZIhOQxh1idLV9wBJoGSwvkPZoiB2ItoPEdAqIxvD8K9nsyQ0epSLR5FFw3FEu-lCxaNapQuShNu7adPqU8r4EZ5e-ECS2uXCfZEvCWHQxnlzQ6_AazsBtiLlOFubK8bpx72PW1n80SmwS4u12RD97--rkmK9uSRoinLadgUKZYWGHDv_Y_vUfX2Q';

     

    <div>some html</div>

     

    After variable text:

     

    <div>some html</div>

     

    <div>some html</div>

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @khhaj 

    Follow the below suggestion with regex value:

    Deenuji_0-1709654161092.png

     

     

    Regex value: const\s+\w+\s+=\s+'.*?';

     

    --------------------------------------------------------------------------------------------------------------------------

    If I've resolved your query, please consider accepting it as the solution and giving it a thumbs up to help others find answers faster.

  • HAKHBIZ Profile Picture
    60 on at

    Many thanks. I make a mistake. It should be this part of text. How should the regex look like?

     

    <input name="__RequestVerificationToken" type="hidden" value="CfDJ8OY4FYnSf9VPtqYcgBx1yo37SrZp8VKbPkGSiE6d4OgU2q9HjleE_9LZSPB-UwPKu9ThNo_XZAj9-MJmEzfpkKgXaXopWCdmbTIcIQp5HdXM-ewXKSq6KKjv1t0wdWi4U8gPm_e2vDZn7p9gWM7UpbzS0yZ7RdQbbxCKAaVR37x3tSViODpeH62n-qjeLWGHFg">

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @khhaj 

    Sure, not a problem. Please modify the regex as follows: I have replaced the entire value attribute with an empty string. If you wish to retain value="" in your input tag then mention that in the replace-with parameter.

    Deenuji_0-1709689495799.png

    Deenuji_1-1709689575909.png

     

    Regex Used: value="[^"]*"

     

    Output:

    Deenuji_2-1709689618797.png

    Code:

    SET NewVar TO $'''<input name=\"__RequestVerificationToken\" type=\"hidden\" value=\"CfDJ8OY4FYnSf9VPtqYcgBx1yo37SrZp8VKbPkGSiE6d4OgU2q9HjleE_9LZSPB-UwPKu9ThNo_XZAj9-MJmEzfpkKgXaXopWCdmbTIcIQp5HdXM-ewXKSq6KKjv1t0wdWi4U8gPm_e2vDZn7p9gWM7UpbzS0yZ7RdQbbxCKAaVR37x3tSViODpeH62n-qjeLWGHFg\">'''
    # Remove complete Value attribute
    Text.Replace Text: NewVar TextToFind: $'''value=\"[^\"]*\"''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> Replaced

     

     

    ----------------------------------------------------------------------------------------------------------------------------

    If I've resolved your query, please consider accepting it as the solution and giving it a thumbs up to help others find answers faster.

     

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 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard