Remove &ZeroWidthSpace Unicode character from a string

While scraping a date from the website I found that it contains ZeroWidthSpace Unicode character and I am unable to parse the date string to a DateTime.

I tried removing the ZeroWidthSpace char by using string.Replace() function like this x.Replace("\u200B", “”).

This works perfectly fine in a C# program, but I cannot remove this char in UI Path. Is this a limitation in the “.Replace()” in UI Path or am I missing something here?

Since the Replace function did not work, I am looping through each character in the string and convert the char to int and check if it equals 8203 (int equivalent), and removing the unwanted char, but this is not an efficient way.

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"\u200B","")

Regards,

1 Like

Thank you very much it worked using Regex.

I could not guess the reason behind the issue with string.Replace() in the UI Path when it works in C# fine. I am guessing it could be to do with .Net version or something else?

1 Like

Hi,

It’s because C# supports \u expression in string literal but VB doesn’t support it.

Regards,

1 Like

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