I have a string:
“Hello, my name is blah blah (goodbye) (hello) (oops)”
How do I remove “(hello)” but leaving the other two bracketed words?
I’m doing this right now in PHP but it removes ALL occurrences of brackets and anything inside them. I want to target a specific word, then remove the word and the surrounding brackets.
$newName= trim(preg_replace('/\s*\([^)]*\)/', '', $name));
Don’t use regex for such an easy operation
in order to remove more values, you don’t even need to use str_replace multiple times, just pass array to the first argument