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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / URLDecode with Office ...
Power Automate
Unanswered

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,187 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,129 Super User 2025 Season 2 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,436 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard