I've been using a RegExp expression in an action to remove bracketed text for many years.
Regular expression: \(.*\)
Replace with:
However, it removes all the bracketed text. I'd like a RegEx expression that will remove one set of bracketed text.
e.g.
ORIGINAL: Escape (The Pina Colada Song) (Original 1979 7inch Single Version)
AFTER ACTION: Escape (The Pina Colada Song)
I've been trying some code but I'm not experienced enough to get the right syntax.
To remove only the last set of bracketed text - and let other bracketed text untouched - you could try this regular expression:
Regular Expression: \s+\([^)]+\)([^()]*)$
Replace with: $1
Format string for the Convert Tag->Tag for the example tag %TITLE%: $regexp(%TITLE%,'\s+\([^)]+\)([^()]*)$',$1)
Search for a white space before an opening bracket and "ignore every closing bracket" until the last closing bracket before the last bracketed text is reached. Group this last one together.
Replace this group with nothing = remove it.
This works for Escape (The Pina Colada Song) (Original 1979 7inch Single Version)
-> Escape (The Pina Colada Song)
but also for Escape (The Pina Colada Song) (Original 1979 7inch Single Version) another Text
-> Escape (The Pina Colada Song) another Text
As always with regular expressions:
Please test it carefully with test data before you use it on all your precious songs!
Thanks for your fast response and solution. It works a treat and means that I can use the code on Titles with single and double bracketed text. Much appreciated. Cheers
As mentioned, this simpler regular expression only works for the case, where you don't have any more text after the last bracketed text.
So it would not work for Escape (The Pina Colada Song) (Original 1979 7inch Single Version) another Text
it works fine for Escape (The Pina Colada Song) (Original 1979 7inch Single Version)
resulting in "Escape (The Pina Colada Song)"