Compare String1 to String2 (String1=String2)

String1 = “ABC123O3”
String2 = “ABC123O3”

String1 is extracted from Workbook (Excel Workbook)
String2 is extracted from DataTable from Website (Extract Data)

If
String1.Equals(String2)
then Write
Pass
Else Write
Fail

When comparing the two variables in debug mode, I see
String1 = @“ABC123O3”
String2 = “ABC123O3”

Why is UiPath adding “@”?
There is not an “@” symbol in the workbook.

The end goal is to have String1 = String2 and Write Pass

Thanks.

Hi @swinter1

UiPath is adding the @ symbol before String1 because it is interpreting it as a verbatim string literal. A verbatim string literal starts with the @ symbol and it allows you to include special characters, such as new lines or tabs, in a string without having to escape them.

To avoid this, you can use:

String1 = String1.TrimStart("@"c)

Hope this helps,
Best Regards.

2 Likes

Hi @arjunshenoy
I had not run into that issue before. Is it interpreting as verbatim because it’s extracted from the workbook?
Thank you for the help.

1 Like

@swinter1

Yes. When UiPath reads a string from an Excel workbook, it reads it as a verbatim string literal by default. This is because Excel allows you to include special characters such as new lines and tabs within a cell, and UiPath needs to be able to preserve those special characters when reading the cell’s value.

Hope this helps,
Best Regards.

@arjunshenoy

Oh. That makes sense.

Again, thank you. Best Regards.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.