How to replace all double double(i.e. "") quotations with a single double quotation?


#1

I am scraping a pdf using ABBYY OCR and I convert the output into a string. In certain places the string contains double double quotations (i.e. “”). For example the string contains: ("“Us”", ““We””, ““You””). There are also other random occurrences of this issue.

I want to replace all occurrences of the double double quotes ("") with a single double quote (").

So I use String.Replace("""","a") and this targets all double double quotes and replaces them with an ‘a’ character. But how can I replace them all with a double quotation character?

I am somewhat shocked that there is no escape character, e.g. the use of the back slash in c#, javascript etc.

Many thanks

Chris


#2

How about using regular expression?
Like this.

replace_all_multiple_dquot.xaml (5.4 KB)


#4

In VB.NET grammar, Two double-quotation in string literal means one double-quotation.

For example,

WriteLine("Hello ""World""")

writes.

Hello "World"

#5

Hi Honoka,

Yeah I know this. Your solution solved the problem for me, many thanks. My original string replace also solves this issue.

My issue turned out to be the output of the debugger that was not as expected. It prints the double double quotes even though the new string does not contain them. I think if does this for reopening the string after the first double quote closes it.

Many thanks

Chris