Regexp to find triple+ repeated characters e.g. aaa, bbb, ...

Hi guys,

I'm trying to find an elegant regular expression to search for occurrences of strings formed by 3 or more repeated characters and replace these with double occurrences.

e.g. "ooooooh I just need a friend" would ideally become "ooh I just need a friend"

My first naive attempt was to try:

$regexp(ooooooh I just need a friend,(.){3,},$1$1)

which produced

Wrapping the comma from the range repeat in single quotes cured the regexp error and:

$regexp(ooooooh I just need a friend,(.){3','},$1$1)

resulted in

That's a bit greedier than I expected so I then try:

$regexp(ooooooh I just need a friend,(.){3','}?,$1$1)

which produces

A bit of trial and error later and a desire not to have to create a monster regular expression searching for a{3} or b{3} etc, and I'm starting to wonder if perhaps the engine is expanding the curly braces before evaluating the regular expression - I guess I'm overlooking a lot here, can anyone help me out?

Thanks in advance!

My allegedly awesome boyfriend has now woken up and solved the problem.
Turns out the solution is:
$regexp(ooooooh I just need a friend,(.)\1\1+,$1$1)

Just to satisfy my curiosity:
What is the point in typing in a regular expression with the length of 51 characters just to delete 4 'o's?

Aha, well since you ask... I use MP3tag to help manage my Ultrastar Deluxe song collection.

"What is Ultrastar Deluxe?", you may ask. Well, it's essentially a Singstar clone for the PC which is fully customizable has the added bonus of allowing players to include their favourite tracks in their song library. To include a new song you'll need the mp3, the corresponding Ultrastar txt file, and you can add background cover art or a music video if you like. Ultrastar txt files can be downloaded from the ultrastar database and many other places and typically look something like this:

#ARTIST:Amy Winehouse
#MP3:Amy Winehouse - Rehab.mp3
#COVER:Amy Winehouse - Rehab.jpg
#VIDEO:Amy Winehouse - Rehab.avi
: 0 3 7 They
: 4 4 7  tried
: 9 3 9  to
: 13 3 12  make
: 17 2 9  me
: 21 7 12  go
: 29 2 9  to
: 33 6 15  re
: 40 2 10 hab
: 42 2 9 ~
: 44 2 7 ~
- 46
: 48 4 7 I
: 52 5 9 ~
: 59 5 12  said
: 64 4 9 ~
: 69 10 12  no
: 79 3 9 ~,
: 84 7 12  no
: 91 3 9 ~,
: 97 5 12  no
- 102
: 4015 4 7 I
: 4019 4 9 ~
: 4024 6 12  won't
: 4030 4 9 ~
: 4036 11 12  go
: 4047 2 9 ~,
: 4052 7 12  go
: 4059 2 9 ~,
: 4064 4 12  go

Once you have (as I do :rolleyes:) quite a sizeable library of hundreds of txts it makes more and more sense to automate as much of the process of prettifying and managing as possible and while software to do just this is available, it's just not as customizable as I'd like.

This is where MP3tag comes in. I have a delightful array of bizarrely convoluted Ultrastar-flavoured MP3tag actions and export configurations to do everything from importing txt-derived lyrics into the corresponding mp3's tags, to exporting first draft Ultrastar txt files from a new mp3's %unsyncedlyrics% tag which I can then fine-tune into the finished article. This way I can load my Ultrastar directory into MP3tag and view multiple aspects of my collection in one window and use this to help me locate and fix variously imperfect songs.

It just so happens that one of my pet peeves is seeing lyrics saturated with character repetitions like "oooooooh" when a more conventional "ooh" seems to work just as well, so this regular expression is now at the centre of a new action to help prettify my hundreds of song lyrics and karaoke txts in one go.

I hope your curiosity is satisfied!

Yes, thank you.
OK, now I can imagine that the ooohs and aaaahs might need a little bit of shortening.
But who, besides Bachmann Turner Overdrive ("you ain't seen n-n-n-nothing yet"), has ever repeated consonants like bbb.
Just kidding. No answer required. have fun karaoking.