I'm not sure I'm asking what is possible. I have a situation
Dim animalList as string = "Dog|Cat|Bird|Mouse"
Dim animal_story_string as string = "One day I was walking down the street and I saw a dog"
Dim hasAnAnimalonList as Boolean
Dim animals() as String = animalList.Split("|")
Dim regex As New Regex("\b" & String.Join("\b|\b", animals) & "\b", RegexOptions.IgnoreCase)
If regex.IsMatch(animal_story_string) Then
hasAnAnimalonList = True
'Here I would like to replace/format the animal found with HTML bold tags so it would look
like "One day I was walking down the street and I saw a <b>dog</>"
End If
In the past I would loop each value in the animalList and if a match is found replace it at that time. Like
For Each animal As string in animals
' I would replace every animal in the list
' If Cat and Birds and Mouse were not in the string it did not matter
animal_story_string = animal_story_string.Replace(animal,"<b>" + animal + "</b>"
Next
Is there a way to do it using a Regex function?