How to remove a word from a string

Hi, Guys!

Let me ask you something. How could I remove the words “Avós paternos” from this string below:

Avós paternos: Antônio Luiz Verissimo e Lucia Maria de Azevedo Veríssimo.

Best Regards,

variable_Name - please save the string in this variable
below line should give the result after : i.e, --> Antônio Luiz Verissimo e Lucia Maria de Azevedo Veríssimo.
variable_Name.Substring(variable_Name.IndexOf(":")+1)

considering you want to extract string after : and remove anything before that

3 Likes

I’ll try, @ArunVelaayudhanG. Thank you!
Could you please explain to me what “.IndexOf()” is used for?

substring method requires the start index i.e, from which position you want to extract.

Here, i want to extract anything after a colon.
Index of Colon will return the index position/location in the string of the colon.

1 Like

I got it, but, what about the “+1”?

so that it doesnt include the colon.
Or else the output will include the colon

1 Like

For single occurrences, you can directly use string.Replace
strBaseText = “Avós paternos: Antônio Luiz Verissimo e Lucia Maria de Azevedo Veríssimo.”
strBaseText = strBaseText.Replace(“Avós paternos”,String.Empty)

In case if there are multiple occurrences of same text as below
strBaseText = “Avós paternos: Antônio Luiz Verissimo e Lucia Maria de Azevedo Veríssimo. Avós paternos
use UiPath.Core.Activities.Replace activity.
Properties: Input: strBaseText
Pattern: “Avós paternos”
Replacement: String.Empty
Result: strBaseText or a new variable

Hope this helps!

1 Like

It worked flawless. Thank you, Madhavi!

1 Like

Thank you! Your case fits better in the case I need. :slight_smile:

1 Like

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