# \[X\] regular expressions not working correctly

**URL:** https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298
**Category:** No Bugs
**Created:** [July 20, 2011, 1:33am UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298 "2011-07-20T01:33:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![chrizoo](https://community.mp3tag.de/user_avatar/community.mp3tag.de/chrizoo/32/233_2.png) [@chrizoo](https://community.mp3tag.de/u/chrizoo)
#### Post date: [July 20, 2011, 1:33am UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298/1 "2011-07-20T01:33:40Z")

</div>

It seems character classes [...] are not working in MP3Tag's implementation of regular expressions, as

**$regexp(%\_tag%,(ID3\w\*)._,$1)_** matches **ID3v1**  
but  
**$regexp(%\_tag%,(ID3[\w])._,$1)_** only matches **ID3** _(should match ID3v1)_  
**$regexp(%\_tag%,(ID3[^]).\*,$1)** only matches **ID3** _(should match ID3v1)_  
   
(%\_tag% = "ID3v1 Lyrics3v2 ID3v2.4 APEv2")

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [July 20, 2011, 3:01am UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298/2 "2011-07-20T03:01:33Z")

</div>

> [@chrizoo](#):
>
> It seems character classes [...] are not working in MP3Tag's implementation of regular expressions ...

Try this ...

**$regexp(%\_tag%,'(ID3\w\*).\*','$1')****$regexp(%\_tag%,'(ID3[\w]\*).\*','$1')****$regexp(%\_tag%,'(ID3[^]\*).\*','$1')**

DD.20110720.0704.CEST

---

<div class="post-metadata">

### Author: ![chrizoo](https://community.mp3tag.de/user_avatar/community.mp3tag.de/chrizoo/32/233_2.png) [@chrizoo](https://community.mp3tag.de/u/chrizoo)
#### Post date: [July 20, 2011, 11:16am UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298/3 "2011-07-20T11:16:35Z")

</div>

your version (with **'...'** wrapped around) works. what is the reason for this? Why are quotes ( **'** ) needed at all?

I finally settled for $regexp(%\_tag%,(ID3\S\*).\*,$1) which also works.

however **\S** and **[^]** is strictly the same thing, so both variants should work.

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [January 18, 2012, 9:24am UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298/4 "2012-01-18T09:24:18Z")

</div>

> [@chrizoo](#):
>
> ... however **\S** and **[^]** is strictly the same thing ...

It is strictly not the same thing.  
Character class \s contains spaces, tabs, and line breaks.  
Character class \S is the negated version of class \s.

DD.20120118.1124.CET

---

<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: [December 28, 2018, 2:30pm UTC](https://community.mp3tag.de/t/x-regular-expressions-not-working-correctly/12298/5 "2018-12-28T14:30:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
