# gexp regular expression problems

**URL:** https://community.mp3tag.de/t/gexp-regular-expression-problems/9325
**Category:** General Discussion
**Created:** [November 12, 2009, 9:07pm UTC](https://community.mp3tag.de/t/gexp-regular-expression-problems/9325 "2009-11-12T21:07:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tjwhale](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@tjwhale](https://community.mp3tag.de/u/tjwhale)
#### Post date: [November 12, 2009, 9:07pm UTC](https://community.mp3tag.de/t/gexp-regular-expression-problems/9325/1 "2009-11-12T21:07:32Z")

</div>

Hi,

I apologize if this isn't posted in the right place. I must be doing something horribly wrong, but I can't see it.

I'm trying to use regexp in an action to edit directory names to produce an Album name. The following is my test case:

"2005 - The Cellar Door Sessions 1970 (Live) [6CD]\CD1".

I want to remove the string " [6CD]", but in a general way so the 6 could be any 1 or 2 digit number. I started with:

$regexp(%\_parent\_directory%,\s[\d{0,2}CD],,0), which resulted in:

REGEXP ERROR: Regular expression Invalid or trailing backslash

I've tried the following expr strings, with the noted results:

'[6CD]' 2005 - The ellar oor Sessions 1970 (Live) []

[\d{0,1}CD]

```
          REGEXP ERROR: Regular expression Invalid or trailing backslash

```

[[0-9]{0,1}CD]

```
          REGEXP ERROR: Regular expression Invalid or trailing backslash

```

[[0-9]CD]

```
          REGEXP ERROR: Regular expression Invalid or trailing backslash

```

'['[0-9]CD']'

```
          2005 - The ellar oor Sessions 1970 (Live) [6]

```

'[' REGEXP ERROR: Regular expression Unmatched [ or [^

[[ SYNTAX ERROR IN FORMATTING STRING]

I don't know how to get the special characters working, or what I might have done to disable them. This is my first attempt with regexp in an Action, so maybe I haven't turned something on?

- Terry

---

<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: [November 12, 2009, 9:32pm UTC](https://community.mp3tag.de/t/gexp-regular-expression-problems/9325/2 "2009-11-12T21:32:37Z")

</div>

$regexp(%\_parent\_directory%,\s'['\d{0','2}CD']',,0)  
or  
$regexp(%\_parent\_directory%,'\s[\d{0,2}CD]',,0)

---

<div class="post-metadata">

### Author: ![tjwhale](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@tjwhale](https://community.mp3tag.de/u/tjwhale)
#### Post date: [November 16, 2009, 1:23am UTC](https://community.mp3tag.de/t/gexp-regular-expression-problems/9325/3 "2009-11-16T01:23:45Z")

</div>

Thanks. I never received an email alert on your reply, but figured out your second suggestion (single quotes around the whole string) working a different problem.
