How to remove certain word from a string

Hi Everyone,

How do I remove certain word from a string? I have tried to use VBA and replace it with “” but it is not the method I wanted. Is there a way where I can use a for each loop to remove the words in the Name Column?

For example,
I would need to remove: Not Correct, and ,Not Correct from the Name column
image

So that it becomes like this:
image

1 Like

It should work within a for each row activity
then inside for each row block

Assign activity:
row(ColNameorIndex) = row(ColNameOrIndex).Replace(“Not Correct”).Trim({" “c,”,"c })

1 Like

Hi you can use a Assign inside a for each and assign the
CurrentRow(“Column”)=System.Text.RegularExpressions.Regex.Replace(CurrentRow(“Name”).ToString, “[,]{0,1}Not Correct[,]{0,1}”, “”).Trim

RemoveSpecialCharacters.xaml (9.9 KB)

1 Like

You can try to replace those with lines of code in invoke code activity

Read the excel and store in dt1

use the invoke code activity and write the following code [dt1 as i/p to invoke code with direction as in/out]

dt1.AsEnumerable().ToList.ForEach(Sub(row) row(“Name”)= System.Text.RegularExpressions.Regex.Replace(row(“Name”).ToString.Trim,“Not Correct,|,Not Correct”,“”))

then write the dt1 in a excel using write range

Thanks & Regards,
Nived N

1 Like

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