Unable to replace using replace function from "" with double quote (")


We are working on a OS project where we consuming external .Net WebAPIs. As a part of implementation, we had requirement to fetch HTML using Web-APIs and show on UI screen.

Under fetched HTML, we had some inline JS functions too for its own functioning.

Currently, we are getting HTML like below snippet

<html id=""StylesheetReport""><head><meta content=""IE=8"" http-equiv=""X-UA-Compatible""></meta><style............

When we use inbuilt function to replace 2 times double quote ("") to a double quote (") under expression, it does not allow since it requires always character and throws compilation error.

Replace(string, """", """);

But, when we try to replace above string to single quote ('), it works for HTML but breaks JS functions   which breaks HTML functioning.

Replace(string, """", "'");

PFA Web-API output as HTML.

Please advise.

Hi Subhash.

You made a mistake in Replace(string, """", """).

Here you are not replacing two double quotes with one. The "" is how you represent " inside " ". So the 4 " symbols represent a single ". And the 3 symbols are not only wrong but invalid.

When you use Replace(string, """", "'") you are replacing one " by one '. Therefore, replacing "" with '' (two single quote, not one double quote).

What you want is Replace(string."""""","""") [6 and 4 times] replace two double quotes by one double quote.