# Error while parsing regular expression

**URL:** https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855
**Category:** General Discussion
**Created:** [September 8, 2012, 8:02pm UTC](https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855 "2012-09-08T20:02:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![paradajz](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/dec6dc/32.png) [@paradajz](https://community.mp3tag.de/u/paradajz)
#### Post date: [September 8, 2012, 8:02pm UTC](https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855/1 "2012-09-08T20:02:55Z")

</div>

I want to extract specific part of folder path and apply it as genre.

Example:

D:\Music\Psybient\Albums\Shpongle\2005 - Nothing Lasts But Nothing Is Lost

D:\Music\Psytrance, Goa\Compilations\1999\Psionic Sounds

Notice the genre? All right.

Why doesn't this work?

```
$regexp(%_folderpath%,D:\\\\Music\\\\([\w ,]+)(\\\\)(.*),$1)

```

I get this error:

Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression fragment '\Music(+HERE)()(.)'..mp3

---

<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: [September 8, 2012, 8:58pm UTC](https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855/2 "2012-09-08T20:58:20Z")

</div>

put the expression in single quotes if it contains chars like [ , that have special functions from the scripting language:

$regexp(%\_folderpath%,'D:\\Music\\([\w ,]+)(\\)(.\*)',$1)

---

<div class="post-metadata">

### Author: ![JJ\_Johnson](https://community.mp3tag.de/user_avatar/community.mp3tag.de/jj_johnson/32/67_2.png) [@JJ\_Johnson](https://community.mp3tag.de/u/JJ_Johnson)
#### Post date: [September 8, 2012, 9:11pm UTC](https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855/3 "2012-09-08T21:11:37Z")

</div>

You can simplify that a little, too

$regexp(%\_folderpath%,'D:\\Music\\([^\\]+)\\.\*',$1)

---

<div class="post-metadata">

### Author: ![paradajz](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/dec6dc/32.png) [@paradajz](https://community.mp3tag.de/u/paradajz)
#### Post date: [September 8, 2012, 9:26pm UTC](https://community.mp3tag.de/t/error-while-parsing-regular-expression/13855/4 "2012-09-08T21:26:36Z")

</div>

Thanks and thanks!
