Getting rid of apostrophes

Hello,

I need to get rid of apostrophes, in case there’s one, to populate a field. The case is: I store last names in a variable, then, I put the that variable/ lastName on a online form. The issue is that the form doesn’t take any special characters like O’hare.

If recommendation of how to get rid of the apostrophe or any special characters when I use the type in activity? Or any other solution?

Thank you!

This is a pretty common issue, especially dealing with SQL statements of any kind. I usually work around it by utilizing String.Replace method

Hi @icosinga

Hope this might be helpful to you if you have any problem with the special character.

https://rpageek.com/uipath-string-manipulation/

cheers :smiley:

Happy learning :smiley:

Thank you! You guys pointed me on the right direction. However I’m running into the issue that besides the last names with apostrophes, I also need to clean the last names with “-“

My code is:
LastName.Replace(“ ‘ “, “ “).ToString this works great but when I add:

LastName.Replace(“ ‘ “, “ “).ToString OR LastName.Replace(“ - “, “ “).ToString

It does’t work. Any ideas how to have them both removed? Or any special character?

Thanks again!

You can chain the .Replace method on. So it would be

LastName.Replace(“ ‘ “, “ “).Replace(“ - “, “ “)

You can just keep adding .Replace at the end with whatever you need. It will work from left to right though, so keep that in mind (i.e. all ’ characters will be replaced first, then - characters will get replaced second). Also note that .ToString isn’t needed because it is already of type string

It works Great!!! Thank you all!!!

1 Like