Remove unwanted repetition at specific part of filename


I've been desperate trying to create a regular expression to remove undesired character repetition to the last word of the prefix. It happens mainly when the prefix ends with a acronym. Example follows:

The Offspring - L.A.P.D..flac

What's the least greedy regex to find two or more repeated characters and convert them to a single one?

Thanks in advance! :slight_smile:

You should have a look to the website of the band ( and recognize that this band has named itself as "LAPD" but not "L.A.P.D.", which is some other department.

So ... do you want to change ...
... from "L.A.P.D." to "LAPD"
... from "L.A.P.D." to "L.A.P.D"

You do not need a "regex", a simple "replace" or "trimRight" should help too.


Hey DetlevD!

Regarding this instance, L.A.P.D. does stand for Los Angeles Police Department. It's an old-school punk rock music criticizing LA police brutality back in the nineties.

Your method would suffice but it's specific for this title only. I was looking for a regex that would preserve the acronym structure removing one or more dots for aesthetic purpose at the end of the title:

Band - Song... T.I.T.L.E....flac > Band - Song... T.I.T.L.E.flac

I have tried to create my own, researched from pre-existing ones but none would return the filename as i wanted which is something simplistic in fact...

$regexp('abc ... def...','\.+','.') ==> "abc . def." $regexp('abc ... def...','\.+$',%DUMMY%) ==> "abc ... def" $trimRight(%_filename%,'.')


I was indeed underestimating the power of $trimRight function! Thank you once again, works perfect! :slight_smile: