I have a string that is a normal sentence. I need to replace the characters in the string if they are found in a given array. For example,
const arr = ["(model: Audi)", "(model: Kia)"];
if the string is:
"How is your (model: Audi) today?";
The result should be "How is your Audi today?".
Is there a way to do this with regex? I read somewhere that regex has better performance. I've tried looping thru the array then replacing the characters but I couldnt get it working and my solution would have nested loops due to the given string
"How is your (model: Audi) today?".replace(/\([^:]+:\s([^\)]+)\)/, '$1')