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 / URLDecode with Office ...
Power Automate
Suggested Answer

URLDecode with Office Script

(1) ShareShare
ReportReport
Posted on by 26

Hello, I want to URL decode the part of the multi-line text HTML in SharePoint if there is an <a href="file:/~</a>.

Since Power Automate does not currently support regular expressions, I was told that using Office Script would be a good option. Could you please tell me how to write it?

I was considering the following, but what do you think?

function main(workbook:ExcelScript.Workbook, targetText:String){
	pattern = new RegExp('<a\\shref=\"file:/.*?</a>','g');
	return targetText.replace(pattern,function(matched) {
        	return urlDecode(matched);
    	});
}

function urlDecode(encodedString:String){
 	 return decodeURIComponent(pattern);
}
I'm currently at home, so I can't use Power Automate.
 
Thanks a lot in advance!
Categories:
I have the same question (0)
  • ivan_apps Profile Picture
    2,189 Moderator on at
    I’m not sure how you would run an office script from inside Power Automate cloud flows, maybe desktop flows if that’s an option for you.
     
    Power Automate expressions do have encodeUriComponent() functions if that’s what you need. It also has a replace() function to substitute the tags you a seeking, with uriEncoded versions of that text.  I’m not entirely sure the complexity of your total flow but if you are just replacing <a/> tags you should be fine with the replace() function.
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at
    Hi 
     
    As you said, regex operation can be acheived via office script for now in power automate. What i understand is you want to extract the hyperlink present under html format <a href="https://www.g.com">M</a> and decode the url obtained. If yes, you can make the office script to extract the url first and pass it to power automate and using decode function provided by power automate- you can decode the url.
     
    something like below.
     
    First use an office script like below
    function main(workbook: ExcelScript.Workbook, targetText: string) {
        let pattern = new RegExp('(?<=\<a href=").*?(?="\>)');
        return targetText.match(pattern)
    }
    
     
    Now use run script action in flow which extracts the url from hyperlink provided as input to script. for demo flow i have used a sample input value.
     
     
     
    expression used in compose action-  
    decodeUriComponent(first(outputs('Run_script')?['body/result']))
     
     
     
    Hope it helps
    Thanks & Regards,
    Nived N 
    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

     Found my answer helpful? Please consider marking it as the solution!
     Your appreciation keeps me motivated. Thank you! 

     
     
     
     
     
     
     
     
     
     
  • Suggested answer
    Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    Dependent on the HTML, xpath() might be an easier way to get the URLs.
     
    E.g.
     
    xpath(
    	xml(outputs('Compose')),
    	'//a/@href'
    )
     

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard