Replace strings found in list of strings from inside a string, does taht make sense?
Similar to ReplaceChars but this one will replace full words in list.
Pass String1, the large string you want to work with, then Strings_to_Remove with is list of strings that we do not want to see in String1 separated by Sepa.
Then we pass Strings_to_put to be put instead of strings from Strings_to_Remove, also separated by Sepa
Is this better?
Function ReplaceStrings(String1, Strings_to_remove, Strings_to_put, Optional Sepa = "|")
' Removes all strings found in Strings_to_remove from String1 and replace them with equivelants from Strings_to_put
' String by String
' Uses Sepa as separator of strings in both Strings_to_put and Strings_to_remove
' Needs CutString3
'
NewStr = String1
Xii = 0
For Each Sttr In Split(Strings_to_remove, Sepa)
Xii = Xii + 1
NewStr = Replace(NewStr, Sttr, CutString(Strings_to_put, Xii, Sepa))
Next
ReplaceStrings = NewStr
End Function
' Removes all strings found in Strings_to_remove from String1 and replace them with equivelants from Strings_to_put
' String by String
' Uses Sepa as separator of strings in both Strings_to_put and Strings_to_remove
' Needs CutString3
'
NewStr = String1
Xii = 0
For Each Sttr In Split(Strings_to_remove, Sepa)
Xii = Xii + 1
NewStr = Replace(NewStr, Sttr, CutString(Strings_to_put, Xii, Sepa))
Next
ReplaceStrings = NewStr
End Function
String1, Strings_to_remove, Strings_to_put, Optional Sepa = "|"
? ReplaceStrings("Something of worlds", "of|some", "to|Any")
Anything to worlds
Anything to worlds
Views 111
Downloads 59
CodeID
DB ID