5

In Azure logic Apps, how can I escape single quotes(') using a replace function?

I have a JSON payload where I have to replace a single quote(') with a double quote("). The expression I've came up with looks like this:

replace(string(@triggerBody()),'/' ','/" ')

But my second expression to escape the single quote (') isn't working.

Jan_V
  • 4,244
  • 1
  • 40
  • 64
ashok
  • 1,078
  • 3
  • 20
  • 63

5 Answers5

6

I resolved this by using a double single quotation, '' thanks to this link

Nic Willemse
  • 101
  • 2
  • 7
2

Summary for single and doubt quotes sharing with others.

  1. String containing single quote ', use extra single quote to escape:

    ''
    
  2. String containing double quotes ", prefix with a forward slash to escape:

    \"
    
  3. Original json (posted from postman):

    {
        "name": "single''dds double\"te",
        "email": "special signle and double quotes",
        "password": "pp@pp"
    }
    
  4. console.log result in sql query in Nodejs environment:

    INSERT INTO ztestTbl(name, email, passowrd) VALUES (N'single''dds double"te', N'special signle and double quotes', N'pp@pp')
    
  5. String insert into the mssql db:

    single'dds double"te
    
RobC
  • 22,977
  • 20
  • 73
  • 80
vantor
  • 21
  • 1
1

This is now you do it. You need 2 single quotes inside the single quote

@replace(string(triggerBody()),'''' ','\" ')
O'Neil Tomlinson
  • 702
  • 1
  • 6
  • 28
0

Try this:

@replace(string(triggerBody()),''' ','\" ')

HTH

Paco de la Cruz
  • 2,066
  • 13
  • 22
0

I had problem escaping single quote in query parameter concat. I resolved it by used double quote. Thanks to tips in this post.

concat('**Text1**', ''**'**' , '**text2**',''**'**')

resulted in :

Text1'text2'

Take a note of four single quotes.

Gustave Coste
  • 677
  • 5
  • 19
Anjan
  • 1