How to replace keywords from given text

How to replace keywords including digit(Highlighted text) with “”.
We are storing UNIT and APT keywords in array variable
arr_Keywords={“UNIT”,“APT”}

UNIT 8 23 OCEAN DRIVE NORTH COOGEE 1111 123456789
66 PARKIN STREET UNIT 6 ROCKINGHAM 2222 0987654321
115 BEACH ROAD PORT APT 34 MELBOURENE VIC 3207 6104456789

HI @Naveen_KK1

Check out the video

Regards
Gokul

Hi @Naveen_KK1

Please use the below

System.Text.RegularExpressions.Regex.Replace(yourString,“UNIT \d+”,“”)

System.Text.RegularExpressions.Regex.Replace(yourString,“APT \d+”,“”)

cheers

1 Like

HI @Naveen_KK1

You can try with Replace method

YourString.Replace("UNIT"," ")

Regards
Gokul

Hi @Naveen_KK1

You can try with this expression

Read Text File | Store it as YourString

Use Assign activity

ArrString = {"UNIT","APT"}

Use Assign activity

System.Text.RegularExpressions.Regex.Replace(YourString,String.Join("|",ArrString)," ").Tostring

Regards
Gokul

Hi @Gokul001 ,
We need to replace digits along with keyword
please check the text we are highlighted that text

Sorry @Naveen_KK1

Check out this expression

System.Text.RegularExpressions.Regex.Replace(YourString,String.Join("\s\d+|",ArrString)," ")

Regards
Gokul

Hi @Naveen_KK1

This would work for the same

cheers

HI @Naveen_KK1

Try with this expression

System.Text.RegularExpressions.Regex.Replace(YourString,String.Join("\s\d+|",ArrString)+"\s\d+","")

Check out the Immediate panel

image

Regards
Gokul

1 Like