Home > Enterprise >  How to replace a single quote with double quotes in ADF dynamic expressions
How to replace a single quote with double quotes in ADF dynamic expressions

Time:07-19

I am trying to replace single quote in a string with double quote using replace function with data factory expressions.

For example, replace single quote in the following string

hello'world ---> hello''world

@replace(pipeline().parameters.tst,''','''')

The above code is not working. Need help in fixing the code

CodePudding user response:

You can declare a new parameter with the value ' (single quote). You can look at the following demonstration for reference.

  • I have taken 2 parameters, text with the value hello'world and replace_char with the value '.

enter image description here

  • I used a set variable activity to store the output of the replace() function (for demonstration) into variable named output (String). Now, I modified the value as:
@replace(pipeline().parameters.text,pipeline().parameters.replace_char,'"')

enter image description here

  • This successfully helps in replacing a single quote with double quote character.

enter image description here

NOTE: The \ in the output variable value indicates that the " is to be considered as a character inside the string value.

  • Related