Let's say I have a string like this:
This is my (2019) awesome string (that I want to modify)
The date in it has to stay, but without parentheses. Meanwhile everything else that is in parentheses has to go. So I would like to achieve this:
This is my 2019 awesome string
I am able to locate the date using this:
\b(201\d{1})\b
And I am also able to locate anything in parentheses using this:
(\(.*\))
But I only want to remove everything if it's not a date in parentheses or else I want to keep the date only removing the parentheses. Is there a way to do this without using if else
?