Problem with quotes in string concatenation and management

Hello,
I am having a silly, scary problem. I can use two double quotes in a string to represent a single quote.
For example “name is ““George””.” which works fine.

But if I try to build this string programmatically, for example parsing a string and adding “”“” in it, I end up with a string like “name is \”\“George\”\“.”
When I use TypeInto with this string, it gets truncated at the first \.

I also tried “name is |George|.” then str.replace(“|”,“”“”) but got the same result.
I’m surprised no one complained about this yet.

Thanks in advance

Hi @george.muammar

You can use the Chr(34) to replace those double quotes like:

strInput.Replace("|", Chr(34))

image
image

Regards

Hi,

How did you check this string? If you checked it at Locals panel, it’s normal because of C# style expression.(Single double quote character is expressed \" in C# string) For now, can you try WriteLine or WriteTextFile activty etc to check it?

Regards,

Hi thanks for your reply. I checked it using the debugging in the locals window.
Also when I do TypeInto a text box into the web page, I get the same value.
My project uses VB not C# formatting of expressions.
For the moment the workaround I have found is to use single quotes and paste the string into the text box, as I am also having problems with [ characters (tried [[ but still doesn’t work well)

Hi,

My project uses VB not C# formatting of expressions.

It may be expressed in C# regardless of the language of the project , at Locals panel.

Can you share more specific information such as screenshot and xaml etc?

I am also having problems with [ characters (tried [[ but still doesn’t work well)

Which input mode do you use? Simulate might solve this problem.

Regards,

BlockquoteIt may be expressed in C# regardless of the language of the project , at Locals panel.

Interesting!

Input mode is Hardware Events, the only one that seems to work well with the web application I am using.

The problem seems related to the string manipulation. Already once I do the replace, I see the backslashes. It also happens with string concatenation. I’m surprised.

In the meantime I’ve used workarounds, but still curious on why this is happening and how to fix. thanks for your help

Hi,

Your string manipulation seems no problem. Can you try to output content of the variable using WriteLine activity?
There will be no backslash in it.

Regards,

Hi @george.muammar

The issue you’re facing is related to the way backslashes are interpreted in string literals.To overcome this issue, you can use the “@” symbol before the string to create a verbatim string literal in C#. This allows you to include the backslashes without any special interpretation.

string str = @“name is ““George””.”;

This is how you can do it-

  1. Assign the verbatim string to a variable using the “@” symbol before the string, like this: str = @"name is ""George"".".
  2. In the “Type Into” activity, use the variable that holds the verbatim string directly in the “Text” property.

Thanks!!