Removing similar strings from a sentence string

Scenario - I retrieve two strings from a website, one is a company name and the other is company address with the name in. I want to remove the company from the address if it’s present but sometimes due to human error a there’s a spelling mistake. how can i still remove the company name if there is a spelling mistake.

Removing the company name has been working with if(string2.contains(string1 + “,”), string2.replace(string1 + “,”,“”).Trim,string2.trim) but if there’s a spelling error it doesn’t work. what can I do to fix this

Please note that this is just an example the spelling mistake could be “Jonh Doe”

String 1 = “John Doe”
String 2= “John Deo, 123 fake street, fake avenue”
expected result = “123 fake street, fake avenue”

@duaine.b

outputstr=If(string2.Split(“,“c)(0).Replace(” “,””).ToLower.trim.Equals(string1.ToLower.Trim),string2,String.Join(“,”,string2.Split(","c).Skip(1).ToArray))

use it in assign activity outputstr is the value

Hi @duaine.b

- Assign -> String 1 = “John Doe”
- Assign -> String 2= “John Deo, 123 fake street, fake avenue”
- Assign -> SplitString = String2.Split(",")   //SplitString is the array of String datatype
- For each activity to iterate the SplitString
- Inside for each insert the If condition and write below condition
- Assign -> ExpectedResult = ExpectedResult+","+CurrentItem.toString

The final output is like 123 fake street, fake avenue

Hope it helps!!