# Remove unwanted repetition at specific part of filename

**URL:** <https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124>\
**Category:** Support\
**Created:** [October 21, 2013, 2:07am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124 "2013-10-21T02:07:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harakiri](https://community.mp3tag.de/user_avatar/community.mp3tag.de/harakiri/32/142_2.png) [@Harakiri](https://community.mp3tag.de/u/Harakiri)\
**Post date:** [October 21, 2013, 2:07am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/1 "2013-10-21T02:07:53Z")

</div>

Hello!

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! 🙂

---

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [October 21, 2013, 3:44am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/2 "2013-10-21T03:44:00Z")

</div>

> [@Harakiri](#):
>
> ... I've been desperate trying to create a regular expression to remove undesired character repetition to the last word of the prefix. ...

You should have a look to the website of the band ([http://www.lapd.ie/about.html](http://www.lapd.ie/about.html)) 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.

DD.20131021.0744.CEST

---

<div class="post-metadata">

**Author:** ![Harakiri](https://community.mp3tag.de/user_avatar/community.mp3tag.de/harakiri/32/142_2.png) [@Harakiri](https://community.mp3tag.de/u/Harakiri)\
**Post date:** [October 21, 2013, 4:26am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/3 "2013-10-21T04:26:15Z")

</div>

> [@DetlevD](#):
>
> You should have a look to the website of the band ([http://www.lapd.ie/about.html](http://www.lapd.ie/about.html)) 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.
> 
> DD.20131021.0744.CEST

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...

---

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [October 21, 2013, 4:40am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/4 "2013-10-21T04:40:25Z")

</div>

> [@Harakiri](#):
>
> ... 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 ...

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

DD.20131021.0842.CEST

---

<div class="post-metadata">

**Author:** ![Harakiri](https://community.mp3tag.de/user_avatar/community.mp3tag.de/harakiri/32/142_2.png) [@Harakiri](https://community.mp3tag.de/u/Harakiri)\
**Post date:** [October 21, 2013, 4:51am UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/5 "2013-10-21T04:51:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:24pm UTC](https://community.mp3tag.de/t/remove-unwanted-repetition-at-specific-part-of-filename/15124/6 "2026-02-09T12:24:43Z")

</div>

Closed on February 9, 2026, 12:24pm UTC


