Remove part of a string


#1

Hello friends,
I need to manipulate the "Contraente " column so that it eliminates the part of the string “ProprietarioCATTANEO MARIKA SONIA” because it contains a repatition of the first part.
20180709.xlsx (22.7 KB)


How can I manipulate the string?
Thank you so much,
Camilla. :slight_smile:


#2

Hey @CamiCat

You can use String.Remove function!

Assuming you only want to change that particular cell , you could do something like this(assuming str is holding the value at specified cell)

str = str.Remove(str.IndexOf(“Proprietario”))

If you are iterating through the whole DataTable you can check
if row(“Contraente”).ToString.Contains(“Proprietario”)
then row(“Contraente”)=row(“Contraente”).ToString.Remove(row(“Contraente”).ToString.IndexOf(“Proprietario”))

Hope this helps :slight_smile:

Cheers!


#3

Thank you so much @Rishabh_Lakhera.
I’ll try with your suggestion and let you know as soon as possible.
Camilla :slight_smile:


#4

Unfortunately I tried your solution but it doesn’t work.
have you kindly got any other ideas?
Thank you so much,
Camilla :slight_smile:


#5

Are you getting an error? Or an unchanged string? Because i tried the same on a test string and it worked fine!


#6

Hi @CamiCat,
I have done the sample for this situation.

File : RemovePartOfAString.zip (18.4 KB)

Regards
Balamurugan.S


#7

Thank you so much @balupad14.
Your solution is very good.
Camilla :slight_smile: