To extract string from a text file

Hi All,
I have a text file where it has specific string “ABC” in multiple rows/places and I want to fetch that string and replace with “BCD” .

Could you please help me with the expression?

ABC
ABC
ABC
ABC

@Nani_Kumar - Use regex replace

Thanks Prasath, I am a newbie and exploring Regex expressions how to write syntax for this expression.
First I have to find the word “AbC” and then replace with “BCD”.
Could you please help me with same?

Hi Nani Kumar

This is my default string values: I want to replace the CCC
image

This is my result with them changed
image

Use an assign

NewSTRValue = YourSTRValue.Replace(“CCC”,“CorrectValues has been changed”)

in your case it would be
NewSTRValue = yourSTRValue.Repalce(“ABC”,“BCD”)

1 Like

Hi @Nani_Kumar try this code using assign activitiy

Assuming u had stored ur string in input varaible

Then use the below code

input = System.Text.RegularExpressions.Regex.Replace(input,“ABC”,“BCD”)

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

2 Likes

@Nani_Kumar
as you requested a case insensitive matching go for following (RegEx)
grafik

System.Text.RegularExpressions.Regex.Replace(YourStringVar,“ABC”,“BCD”,RegexOptions.IgnoreCase)

Help for Regex have a look here:

3 Likes