How to escape singlequote(') in azure logic app expression replace function - azure

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.

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

Summary for single and doubt quotes sharing with others.
String containing single quote ', use extra single quote to escape:
''
String containing double quotes ", prefix with a forward slash to escape:
\"
Original json (posted from postman):
{
"name": "single''dds double\"te",
"email": "special signle and double quotes",
"password": "pp#pp"
}
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')
String insert into the mssql db:
single'dds double"te

This is now you do it. You need 2 single quotes inside the single quote
#replace(string(triggerBody()),'''' ','\" ')

Try this:
#replace(string(triggerBody()),''' ','\" ')
HTH

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.

Related

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

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
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 '.
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,'"')
This successfully helps in replacing a single quote with double quote character.
NOTE: The \ in the output variable value indicates that the " is to be considered as a character inside the string value.
Use two single quotes to escape a ' character in string functions.
For example, expression #concat('Baba', '''s ', 'book store') will return below result.
Baba's book store
https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#escaping-single-quote-character

How to escape double quotes in a parameter in Azure Data factory

I have a pipeline parameter called myArray:
with following structure:
[
{
“Mapping“: “{ “sourceCol“: “ColA“ }“
“AnotherProperty“: 1
}
]
How can I escape the double quotes around sourceCol and ColA. As it seems that ADF is adding automatically a / to them.
In Azure data factory, backslash / appears wherever double quotes are used.
To avoid it, you can use replace() function to replace double quotes from the string or convert it to JSON.
You can check similar links 1 & 2 for reference.

nodejs how to replace ; with ',' to make an sql query

I have a query that looks like this:
INSERT INTO table VALUES ('47677;2019;2019;10T-1001-10010AS;A05;International;TieLineKoman-KosovoB;L_KOM-KOSB;2018;NULL;NULL;;NULL;Tieline;NULL;10XAL-KESH-----J;0;3')
that is produced by parsing a csv file.
The query is not in a valid form, I have to replace all semicolons with the string ',' (comma inside single quotes). What I want to get is:
('47677','2019','2019','10T-1001-10010AS','A05','International','TieLineKoman-KosovoB','L_KOM-KOSB','2018','NULL','NULL','','NULL','Tieline','NULL','10XAL-KESH-----J','0','3')
I have tried to do this in many different ways, but I end up with backshlashes added in my string. This is what I get:
"INSERT INTO AllocatedEICDetail VALUES ('47677\\',\\'2019\\',\\'2019\\',\\'10T-1001-10010AS\\',\\'A05\\',\\'International\\',\\'TieLineKoman-KosovoB\\',\\'L_KOM-KOSB\\',\\'2018\\',\\'NULL\\',\\'NULL\\',\\'\\',\\'NULL\\',\\'Tieline\\',\\'NULL\\',\\'10XAL-KESH-----J\\',\\'0\\',\\'3')"
Any ideas how to do this properly without having the backslashes added?
Thank you!
//the string you have
const string = '47677;2019;2019;10T-1001-10010AS;A05;International;TieLineKoman-KosovoB;L_KOM-KOSB;2018;NULL;NULL;;NULL;Tieline;NULL;10XAL-KESH-----J;0;3';
//the string you need:
const targetString = string.replace(/\;/g,',');
You specify a small regex between the forward slashes in replace which is a simple ';', give it a 'g' flag for global which will replace all instances, and in the second argument supply what you need it replaced with.

Nested strings for text(,format) conversion

How do you use Text() with a format that has a string inside it ?
=TEXT(A1,"Comfi+"#0"(JO)";"Comfi-"#0"(JO)")
Tried """ both the inner string :
=TEXT(A1," """Comfi+"""#0"""(JO)""";"""Comfi-"""#0"(JO)""" ")
Same result with &char(34)&
Similar issue here, but I couldn't transpose the solution to my problem : How to create strings containing double quotes in Excel formulas?
Post Solution edit :
Building an almanac/calendar with the following (now fixed)formula :
=CONCATENATE(
TEXT(Format!K25,"d"),
" J+",
Format!S25,
" ",
TEXT(Format!AA25,"""Comfi+""#0""(JO)"";""Comfi-""#0""(JO)"""),
" ",
Format!AI25
)
Giving the following output in each cell :
9
J+70
Comfi+21(JO)
CRG
You've got too many quotation marks inside:
=TEXT(A1,"""Comfi+""#0""(JO)"";""Comfi-""#0""(JO)""")
You were tripling many of the inside quotation marks.
Personally, doubling up double-quotes within a quoted string is something I try to avoid at all costs. You can 'escape' the text into literals with a backslash.
=TEXT(A1,"\C\o\m\f\i+#0\(\J\O\);\C\o\m\f\i-#0\(\J\O\)")
'alternately
="Comfi"&text(a1, "+#0;-#0")&"(JO)"
Not all of those actually need to be escaped; only reserved characters. However, I usually escape them all and let Excel sort them out.

Is there a way to add quotes to a multi paragraph string

I wrote the following line:
string QuoteTest2 = "Benjamin Netnayahu,\"BB\", said that: \"Israel will not fall\"";
This example went well, but what can I do in case I want to write a multi paragraph string including quotes?
The following example shows that puting '#' before the doesn't cut it..
string QuoteTest2 = #"Benjamin Netnayahu,\"BB\", said that: \"Israel will not fall\"";
The string ends and the second quote and the over just gives me errors, what should I do?
Use double quotes to escape ""
e.g.
string QuoteTest2 = #"Benjamin Netnayahu,""BB"", said that: ""Israel will not fall""";

Resources