Hello How to replace text in text file

How to Replace text we can do this stringVariable.replace(“cat”,“Dog”)
But my question is how to replace number of words in a text.
For example, I have an excel file I want to read that data and we have to replace text what we get the data from the number of coloumn from the excel and we have the number of rows also so how to replace all of that.

Thanks
Chethan P

Hey,

You can user String.Format method.

For example: SampleString = Hi {0} , Welcome to {1}.

In Bot: String.Format(SampleString,“Copy_Writes”,“UiPath”)

Output : Hi Copy_Writes, Welcome to UiPath.

Give index value in your text whereever you wants specific word, and extract word from excel it will replace it in the string.

Let me know in case of any concern.

Regards,
Sahil

2 Likes

Thanks Is it work because I read the text and it Was HTML code in that we have change lot of things by reading the excel sheet according to that column it will change. so am asking it will work.

Thanks
Chethan P

Hi,

It will works untils the type of text is of String type.

Whatever the text is, it will work .

Regards,
Sahil

1 Like

Thank you very much and I try like this its working String.replace(“”,“”).Replace(“”,“”)…Up to replace complete
Like this is the correct way.

It depends on requirements, Both ways will work fine in terms to replace text.

We just have to see which is more suitable to the requirement.

Regards,
Sahil Garg

1 Like

Thank you very much for your solution and explanation it was really helpful to me
and thanks for giving your valuable time :beer: :beers:

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