How do I remove the " and ” characters?

Hi.
From the Excel cell I download text in the form of strings. Sometimes they have two different types of quotation marks “-char (34) or ” I would like to remove them, but only if they appear at the end of the text. I use the text.TrimEnd (”“”“c) method for this but it only works for one kind of quotation mark. How to write the arguments of the trimEnd metod so that it works with the other quotation marks?
text.TrimEnd (”””"c) not work, but does not cause any error either. It just doesn’t remove the quotation mark.
for illustration, both characters are decoded:
Adnotacja 2022-10-27 142212

Hi
Check this code in assign activity:

Regex.Replace(yourString,"["""+Chr(148)+"]$","")

It should remove both kind of quotation marks only if they are at the ond of the string.

Hi @Slawek_Antoniewicz

if you Want to Remove both “” and ”“ you can try
Replace Function like this

"yourstring”“”“".Replace("”“"c& """"c," ").Trim

Thanks
Harivishnu

But I have to remove the quotation marks at the end of the text only. Sometimes they appear inside and then they have to stay.
And these quotation marks do not always appear at the end of the text.

and when i tried checking your suggestion


a got erros message:
Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

Hi,

If you already know character code (unicode) to be removed, the following will work.

System.Text.RegularExpressions.Regex.Replace(yourString,"[\u0022\u0094]+$","")

Regards,

1 Like

HI
It almost worked.
Unfortunately, we


still need to take into account the code page somehow?

Error message:
Assign: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Hi,

The following post will help you.

Regards,

HI Yoichi

Unfortunately, test with the text ““Łódzkie” support the integration of foreigners” returned all quotation marks unchanged using your expression

Hi,

The above expression is same as TrimEnd. If you need to delete all quote, the following works.

System.Text.RegularExpressions.Regex.Replace(yourString,"[\u0022\u0094]","")

This expression removes character 0x22 and 0x94. If your string contains other double quote character, please add its code. Or can you share your string as a file using WriteTextFile activity? Because, in this forum, some characters are automatically converted to other.

Regards,

we can use here an char array

demo:
grafik

So the idea is to bring the different quotes within an char array
e.g. (we used "Łódzkie““" but immediate panel has a different visualization)
grafik

Another forced approach could be:
YourString.TrimEnd(System.Web.HttpUtility.HtmlDecode("“”"").toCharArray)
But for this we have manually to add the System.Web assembly by manually editing the XAML

Another Variation combining along with @Yoichi Unicode could be
grafik

YourString.TrimEnd(System.Text.RegularExpressions.Regex.Unescape("\u201E\u201C\u201D\u0022").ToCharArray)

From where we following ASC outputs can derive:
grafik

Hi Yoichi
It worked:
helped me your post in discussion

img20220318-3
img20220318-2

after this method is called correctly, t.trimEnd(char(148)) works

HI @ppr PPR
Thank you for your suggestions and commitment. We solved the problem after hints @Yoichi . It consisted not of an incorrect trimEnd call, but of settings at the Encoding.RegisterProvider level.

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