Strings don't match? Is this a bug?

Good morning Everybody,

I have a situation where I run a SQL query against the Excel file(using the OLEDB driver) and output the results to the Output DataTable(String1). Then I use remove couple words from this string using the Remove(index), and then I use an If condition to compare the String1 to String2. Unfortunately, the result of the If statement is always False. I used the “Equals” and “=” as well but looks like something is not right. As well I tried to ToLower and ToUpper and it didn’t help as well. The output of both String1 and String2 are exactly the same on the Log Message and Write Line activities. Can you please point me where I might be missing some details?

1 Like

Hi @Thrall

Try string1.tostring.compareTo(string2)

Ashwin S

Hi @Thrall

You can also try with the Replace(index) to remove the words you dont need and then use the sentence compareTo


Hi buddy @Thrall
Can i have a view on the output of string1 and string2
we can get that with writeline activity and share the screenshot of those two values in output panel
We can solve this buddy, you were almost done
Cheers @Thrall


Unfortunately, it didn’t work.


Yes, I did :slight_smile: And the issue is not in this function

Hi @Palaniyappan

Please find the screenshot attached below

1 Like


I am wondering if the issue in the way that UiPath threats the strings. Please have a look at the string properties from Output DataTable and the target string which it will be compared.002 001

try with Regular Ex and remove the unwanted spaces and compare the sentences.

1 Like

@Thrall Try this


Kindly try with this and let know buddy
in a if condition and try @Thrall
the reason is there might be some space before or after the strings from table, so we are using TRIM method to remove the empty space that lies before and after the string
This will work for sure buddy
Cheers @Thrall


Thank you, for some reason, UiPath was treating my string with space. After Trimming the string it started working properly.

Thank you very much. After Trimming it started working properly. It is working fine even without explicit converting it ToString.

1 Like

Thank you very much

1 Like

Thanks everybody, my issue resolved. Much appreciated for your help and quick responses.

Kind Regards,

Fantastic buddy
Cheers @Thrall
Keep going

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