top of page
Writer's pictureTony Ogilvie

Escaping Single Quotes in PowerAutomate



I had a requirement recently to remove a single quote from a string in one of my PowerAutomates.


Simple enough you might think. Just use the 'replace' expression, right?


e.g.,

replace(string to process, text to replace, text to replace with)

So, initially I used the expression below :

replace(item()?['Column Display Name'],''','')       <- WRONG!

BUT IT DIDN'T WORK!


Why? Because you need to escape the single quote you are replacing - which means placing an extra single quote in front of it.


So the correct expression is:

replace(item()?['Column Display Name'],'''','')      <- RIGHT!

Much better :-)

2,933 views2 comments

2 Σχόλια


pricen
06 Δεκ 2023

I think that

replace(item()?['Column Display Name'],'''','')<-RIGHT!

should be this

replace(item()?['Column Display Name'],'''','''''')<


Regards


Nigel

Μου αρέσει
Tony Ogilvie
Tony Ogilvie
30 Οκτ
Απάντηση σε

Hey Nigel - Good to hear from you!


Thanks for the comment - but the requirement was to remove the apostrophe from the string - and so the original expression in the blog post is correct for achieving this ☺️


The expression you provided will actually duplicate the apostrophe rather than remove it - you can see what I mean in the Power Automate screenshot below. The Compose 1 action is using the expression in the Blog Post (removing the ' from the string Mary's Bar ), while the Compose 2 action is using your expression - which actually duplicates the apostrophe 😊


Cheers,


Tony



Έγινε επεξεργασία
Μου αρέσει
Otagem Logo Wider.png
bottom of page