# regular expression help

**URL:** https://community.mp3tag.de/t/regular-expression-help/2908
**Category:** General Discussion
**Created:** [February 16, 2006, 2:40am UTC](https://community.mp3tag.de/t/regular-expression-help/2908 "2006-02-16T02:40:06Z")
**Posts on this page:** 7
**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: [February 16, 2006, 2:40am UTC](https://community.mp3tag.de/t/regular-expression-help/2908/1 "2006-02-16T02:40:06Z")

</div>

I'm worthless when it comes to regular expressions, was hoping someone could help me out.

I'm looking to extract a portion of the full path including filename starting at either \Music\ or \My Music\ and ending prior to the last slash before the actual filename.

Example:  
_Filename Option A_ - C:\Documents and Settings\Logan\My Documents\My Music\Dance & DJ\DJ Tiësto\Just Be\01 - Forever Today.mp3  
  
_Filename Option B_ - M:\Music\Dance & DJ\DJ Tiësto\Just Be\01 - Forever Today.mp3

_Result_ - DJ Tiësto\Just Be

A brief explanation of how the expressions does this would be greatly appreciated as well, I'm working on learning how to create my own.

---

<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: [February 17, 2006, 1:28pm UTC](https://community.mp3tag.de/t/regular-expression-help/2908/2 "2006-02-17T13:28:44Z")

</div>

If you use an action Format value with %\_parent\_directory%\%\_directory% is that what you want?

---

<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: [February 17, 2006, 3:28pm UTC](https://community.mp3tag.de/t/regular-expression-help/2908/3 "2006-02-17T15:28:33Z")

</div>

> [@](#):
>
> If you use an action Format value with %\_parent\_directory%\%\_directory% is that what you want?
> 
> \<{POST\_SNAPBACK}\>

Not neccessarily, if I have a multipe disc album there could be a '\disc 01' in the path.

---

<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: [February 17, 2006, 4:17pm UTC](https://community.mp3tag.de/t/regular-expression-help/2908/4 "2006-02-17T16:17:40Z")

</div>

When you say start at \Music\ wouln't the result have to be _Dance & DJ\DJ Tiësto\Just Be_ ?  
And what would be the result from a path with disc number?

---

<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: [February 17, 2006, 8:31pm UTC](https://community.mp3tag.de/t/regular-expression-help/2908/5 "2006-02-17T20:31:51Z")

</div>

> [@](#):
>
> When you say start at \Music\ wouln't the result have to be _Dance & DJ\DJ Tiësto\Just Be_ ?  
> And what would be the result from a path with disc number?
> 
> \<{POST\_SNAPBACK}\>

Yes, that is the correct result.

If 'Just Be' were a multiple disc album though, it would return _Dance & DJ\DJ Tiësto\Just Be\Disc 01_

---

<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: [February 17, 2006, 9:58pm UTC](https://community.mp3tag.de/t/regular-expression-help/2908/6 "2006-02-17T21:58:07Z")

</div>

Expression: ^._?(\\Music\\|\\My Music\\)(._)\\[^\\]+$  
Replace with: $2

---

<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: [February 18, 2006, 2:05am UTC](https://community.mp3tag.de/t/regular-expression-help/2908/7 "2006-02-18T02:05:55Z")

</div>

> [@](#):
>
> Expression: ^._?(\\Music\\|\\My Music\\)(._)\\[^\\]+$  
> Replace with: $2
> 
> \<{POST\_SNAPBACK}\>

Perfect, thanks!
