# Regular Expression assistance

**URL:** https://community.mp3tag.de/t/regular-expression-assistance/945
**Category:** General Discussion
**Created:** [March 31, 2004, 10:59pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945 "2004-03-31T22:59:07Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [March 31, 2004, 10:59pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/1 "2004-03-31T22:59:07Z")

</div>

Ok, need a little help here....

First off, anyone know of a good Regular Expression tutorial ? I'd like to learn how to do this myself...

While I dig around for one, would appreciate it if someone could enlighten me as to how I do the followig :

- search for x-x and replace with x - x where x is any character
- change the string _track - artist - title (pres artist2) (mix\_name)_ to _track - artist pres artist2 - title (mix\_name)_

Fun facts about the second one : 
- 'track' and '(mix\_name)' are optional
- 'pres' may be 'feat' or 'vs.' - but all files will have one of the three

I would **_greatly_** appreciate any assistance offered.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [April 1, 2004, 6:39am UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/2 "2004-04-01T06:39:12Z")

</div>

1:  
(.)-(.)  
$1 - $2

2:  
^(\d{1,2}\s-\s)?(._)\s-\s(._)\s((._))(\s(._))?  
$1$2 $4 - $3$5

Mp3tag helpfile is good

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [April 5, 2004, 7:27pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/3 "2004-04-05T19:27:21Z")

</div>

Thanks for the help d4n0, but the second one didn't quite work.

Your suggestion resulted in :  
track - artist mix\_name - title (pres artist2)

when I am looking for :  
track - artist pres artist2 - title (mix\_name)

When I broke the results down into $1 - $2 - $3 - $4 - $5, it does not appear to be seperating the string _title (pres artist2)_ into two compenents.

I checked the help file as you suggested, but apparently I am daft...

Any more suggestions ?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [April 5, 2004, 8:29pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/4 "2004-04-05T20:29:37Z")

</div>

i have no clue why title (pres artist2) is always together ☹

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 6, 2004, 7:28am UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/5 "2004-04-06T07:28:05Z")

</div>

Check the greedyness of the repeats in the parenthesis part. The regular expression  
**^(\d{1,2}\s-\s)?(._)\s-\s(._)\s((._?))(\s(._?))**  
should work.

Best regards,  
~ Florian

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [April 6, 2004, 7:43am UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/6 "2004-04-06T07:43:09Z")

</div>

it does not work when there is no (mix\_name) at the end

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 6, 2004, 7:58am UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/7 "2004-04-06T07:58:37Z")

</div>

Oh yes, you're right! I've changed all repeats to be non-greedy in your regular expression and now it should work for both cases.

**^(\d{1,2}\s-\s)?(._?)\s-\s(._?)\s((._?))(\s(._))?**  
**$1$2 $4 - $3$5**

Best regards,  
~ Florian

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [April 6, 2004, 1:10pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/8 "2004-04-06T13:10:14Z")

</div>

awesome, yes seems to be fine now  
and i gotta find out what greedyness exactly is 😃

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 6, 2004, 1:37pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/9 "2004-04-06T13:37:30Z")

</div>

> [@](#):
>
> and i gotta find out what greedyness exactly is 😃

You can translate greedyness with "Gierigkeit". Greedy (standard) repeats are eating as much characters as possible - the non-greedy ones (those with the question mark after the repeat character) don't 🙂

~ Florian

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [April 6, 2004, 4:32pm UTC](https://community.mp3tag.de/t/regular-expression-assistance/945/10 "2004-04-06T16:32:49Z")

</div>

you guys rock....
