# Help with Reg Ex / action

**URL:** https://community.mp3tag.de/t/help-with-reg-ex-action/9642
**Category:** Support
**Created:** [January 4, 2010, 9:27pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642 "2010-01-04T21:27:47Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 4, 2010, 9:27pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/1 "2010-01-04T21:27:47Z")

</div>

If a title contains the string **[Previously Unreleased** how do I replace the title with what's to the left of **[Previously Unreleased**? I'm selecting about 100 tracks, so the action needs to work with titles that don't contain that string (i.e. no action)

Cheers

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 4, 2010, 9:31pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/2 "2010-01-04T21:31:24Z")

</div>

Hi there.

I think it will work:  
Action: Replace with regular expression  
Field: TITLE  
Regular expression: (.\*?)([Previously\sUnreleased)  
Replace matches with: $1

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 4, 2010, 11:14pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/3 "2010-01-04T23:14:56Z")

</div>

Thanks. I'll try and work it out, but

Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song

became

Everybody's Alone Song] Song]/Previously Unreleased Song

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 5, 2010, 12:01am UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/4 "2010-01-05T00:01:25Z")

</div>

So you did not write your problem properly. The script does what you asked for, you have other problems here, what is it then, a title can randomly have the text "Previously Unreleased Song" for a random number of times with or without brackets and a / char?? LOL that is weird.

Read your first opening comment again and try to fix it so that everybody understands it.

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 5, 2010, 10:41am UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/5 "2010-01-05T10:41:45Z")

</div>

I would like  
Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song  
to become  
Everybody's Alone

but  
ABCD [Live at the Ally Pally]  
to stay as it is

and XYZ with no other ['s in the title to stay as XYZ too

Thank you

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 5, 2010, 1:06pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/6 "2010-01-05T13:06:14Z")

</div>

OK. If ALL your problematic tracks start with "[Previously".... then this wil remove everything after it:  
(._?)([Previously._?)  
Replace matches with: $1

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 5, 2010, 7:32pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/7 "2010-01-05T19:32:56Z")

</div>

> [@Tarc](#):
>
> OK. If ALL your problematic tracks start with "[Previously".... then this wil remove everything after it:  
> (._?)([Previously._?)  
> Replace matches with: $1

Sadly, this was similar behaviour to before  
Everybody's Alone [Previously Unreleased Song] [Previously Unreleased Song]/Previously Unreleased Song  
became  
Everybody's Alone Unreleased Song] Unreleased Song]/Previously Unreleased Song

I had a look at some examples, e.g. TagsLikeThese and agree with the principle, but I guess because there are multiple occurrences of the same string, this is throwing it

I have got around this now by doing it manually with a normal text replace, which is sufficient thank you

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 5, 2010, 9:34pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/8 "2010-01-05T21:34:06Z")

</div>

Actually there's 100's of variations of these and it's a pain going through all the variants. I am going to start a new thread if that's ok, as I think it's a filename length problem that I am creating with a tag -\> filename conversion

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 6, 2010, 1:09pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/9 "2010-01-06T13:09:15Z")

</div>

It was my bad, I overlooked something, I fiexed it now. I shouldn't have used the "?", simply remove the last question mark. But the script below will remove any extra spaces too so the new title will end properly.

Regexp:  
**(._?)(\s_)([Previously.\*)**  
Replace with: $1

So.. it works with any title that has the junk at the end starting with "[Previously" and removes everything else to its right.  
Tested it with many examples, if it still doesn't work, let me know.

I'm no expert myself either, but I thought it's useful to try and help you, even though it took me 3 tries.

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 6, 2010, 8:58pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/10 "2010-01-06T20:58:41Z")

</div>

Thanks a million - I appreciate mate. I do have unix experience, but sed / grep / awk were never my forte, and I was curious about the ? too, which was throwing me a bit

I'm not 100% sure of the difference between these  
(._?)(\s_) and  
(._)(\s_)

I did try having a look at your DJ Hidden query, but until I understood this one (which I have only just loaded) I wouldn't have a chance.

Thanks once again

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 6, 2010, 9:43pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/11 "2010-01-06T21:43:25Z")

</div>

No prolem mate.

About the question mark:  
Every symbol or special character has a property called being "greedy" which means they do not stop at the very first occurrence of the character to its right but matches the last possible one.

So in this example (._)(\s_)  
Here we look for two characters, any character+a space.  
But that can happen multiple times throughout the text, so it will not stop at the first place it occurs.  
To force it to stop at the very first occurrence of "any character+space", use "?" after the "any character".

Thus the (._?)(\s_)

---

<div class="post-metadata">

### Author: ![sweep](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@sweep](https://community.mp3tag.de/u/sweep)
#### Post date: [January 6, 2010, 11:16pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/12 "2010-01-06T23:16:26Z")

</div>

Brilliant explanation

Cheers

---

<div class="post-metadata">

### Author: ![Tarc](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/9fc348/32.png) [@Tarc](https://community.mp3tag.de/u/Tarc)
#### Post date: [January 7, 2010, 1:32pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/13 "2010-01-07T13:32:38Z")

</div>

You're welcome - I learn as I go through these as well 😉

---

<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:22pm UTC](https://community.mp3tag.de/t/help-with-reg-ex-action/9642/14 "2026-02-09T12:22:04Z")

</div>


