# Can't use brackets for a $regexpr within an Action script

**URL:** <https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853>\
**Category:** Support\
**Created:** [January 29, 2023, 4:11am UTC](https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853 "2023-01-29T04:11:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flamiusrex31](https://community.mp3tag.de/user_avatar/community.mp3tag.de/flamiusrex31/32/13185_2.png) [@Flamiusrex31](https://community.mp3tag.de/u/Flamiusrex31)\
**Post date:** [January 29, 2023, 4:11am UTC](https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853/1 "2023-01-29T04:11:00Z")

</div>

Hi everyone, I was messing around with the Actions feature and wanted to make a script that ONLY fills ARTISTSORT with the artists' names that start with "The", "A" or "An" (and their Spanish equivalents), but leaving it empty otherwise. I came up with this script:

**$if($eql($regexp(%artist%,^(An?|The|El|Las?|Los?|Una?s?|Unos)\s,),%artist%),,$regexp(%artist%,^(An?|The|El|Las?|Los?|Una?s?|Unos)\s,))**

Worked like a charm, but then I realized that only works when the articles have an uppercase. So, I decided to fix the regex to be more efficient by matching upper and lowercases and using brackets for words with similar characters (e.g., unos / unas). This was the result:

**$if($eql($regexp(%artist%,^([Aa]n?|[Tt]he|[Ee]l|[Ll][ao]s?|[Uu]na?|[Uu]n[oa]s)\s,),%artist%),,$regexp(%artist%,^([Aa]n?|[Tt]he|[Ee]l|[Ll][ao]s?|[Uu]na?|[Uu]n[oa]s)\s,))**

And... nothing happened. I double checked everything and apparently the syntax of the script and the regex were ok (I checked it on [RegExr.com](http://RegExr.com)). Then I started to test it little by little to find out what part was causing problems. I tested it with this script first:

**$if($eql($regexp(%artist%,^The\s,),%artist%),,$regexp(%artist%,^The\s,))**

Worked again... then I tried with this one:

**$if($eql($regexp(%artist%,^[Tt]he\s,),%artist%),,$regexp(%artist%,^[Tt]he\s,))**

And what do you know... it stopped working. Apparently, the brackets were causing problems.

So, I gave up and used the first script I mentioned for uppercase words and duplicate it for the lowercase ones. It's a workaround, but it left me wondering if I'm using the brackets wrong. Does the script parse the brackets in a different way? (Checked the documentation with no results on that subject) Am I overlooking something? Am I that stupid? Is a mp3tag bug? Can't figure it out.

Any kind of advice would be appreciated for sure. Thanks in advance.

PS: If there's a more efficient script or Action, let me know too if posible, please.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [January 29, 2023, 9:52am UTC](https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853/2 "2023-01-29T09:52:15Z")

</div>

For the case **IN** sensitive search in [regex](https://docs.mp3tag.de/scripting/#string-functions):  
The `$regexp()` [function](https://docs.mp3tag.de/regex/) can be made case insensitive by using the 4th parameter: `1`

 ![image](https://community.mp3tag.de/uploads/default/original/2X/9/9f34b346e5ae20971700ace7ddd1341a7760ef6f.png)

For the problem with the [brackets:](https://docs.mp3tag.de/format/#characters-with-special-functionality) you need to put the single quote around them if you want to use it unparsed:  
**Characters with Special Functionality**

 ![image](https://community.mp3tag.de/uploads/default/original/2X/b/ba40e4822826d98c994d514d3341cc1033e834da.png)

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [January 29, 2023, 10:03am UTC](https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853/3 "2023-01-29T10:03:23Z")

</div>

If you use the function `$eql` you compare two values. Searching for a word like "The" in the content of ARTIST would only return TRUE if this word would be the only content, not part of a longer string.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/d/ddc4dd55effb12f12539f5e879095953b3f75ff6.png)

If you want to check if the word "The" exists in in ARTIST (lets say like in "The Beatles") you can try one of the 3 existing [str-functions](https://docs.mp3tag.de/scripting/#string-functions):

 ![image](https://community.mp3tag.de/uploads/default/original/2X/a/a59999b088ce63c82cc08bd4aee584219e1c58d9.png)

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:30pm UTC](https://community.mp3tag.de/t/cant-use-brackets-for-a-regexpr-within-an-action-script/59853/4 "2026-02-09T12:30:02Z")

</div>


