Hi I would really appreciate some help in forming a regex that removes a percentage from the end of a string:
Film name (2009) 58% -> Film name (2009)
Film name (2010) 59% -> Film name (2010)
The string may or may not have the bracketed year. Before the bracketed year, the film name may be alphanumeric and have multiple words.
I am using ‘bulk rename utility’ so am looking to fill in the ‘match’ and ‘replace’ fields.
The best I could come up with was:
([A-Z][a-z]*) \((\d*)\) (\d*\%) --> \1 (\2)
though this only seemed to work with single word film names, and lost the brackets so I had to re-add!
I’ve google and every time I try possible expressions it doesn’t work in the ‘bulk rename utility’ which I believe is based on pcre (Bulk Rename Utility).
To avoid replacing the wrong things do this
and replace it with nothing.
It stops at word boundaries (ie 30% is ok but w30% is not) and gets only 100 or 0-99 numbers.
EDIT:
If the % is the last char of the string you can achieve a better result in doing
this way you get only the
%at the end of the line avoiding to remove numbers with % from the title of the film.If the string is a filename and you need to replace it and you can’t just remove a part of the tile you can do this
and replace with
\1and\2should not be used in a replacement expression. They are regex patterns that match what the first and second capture matched.$1and$2are variables that contain what the first and second capture matched, so you should use those instead.