Problem: I have a string that has "tags" from a list called "listOfTags". If the string contains one of these "tags" from the list I want to be able to remove these "tags" from the string.
What I tried: I first tried traversing through "listOfTags" and appending each "tag" to an empty string variable called x. Then, I tried to remove the "tags" from another string variable called y by using the string.replace method.I then realized that this method would only return what I wanted if the "tags" appeared in the order that they were appended in the variable x.
The algorithm I created is as follows:
if a string contains as a sub-string any strings specified in a particular list: remove the substring from the string
An example of the problem:
listOFTags = ["#tag", "#bold", "#merge"]
string = "#tag #bold bob #merge"
#execute algorithm here
How do I get a string returned that has the text "bob"?
What I want returned:
new_string = "bob"