Probelm with regexp...

I'm trying to extract an artist from a title and I'm running into issues.
I've tried regexp web testers and the code seems fine. But when I use it in MP3Tag.. I get an errors.

example title:
I'm Every Woman [Whitney Houston]

Format value
Format string: $regexp(%title%,(.) [(.)],$2)

This is the error I get:
REGEXP ERROR: Regular expression

Escape sequence terminated prematurely. The error occurred while parsing the regular expression: '(.*) >>>HERE>>>'.

What am I missing? This isn't a complicated expression. I tried double escaping the [ with \\[
but that didn't help.

You are missing the Mp3tag Scripting Syntax
If you are using one of these characters: []$%,()
you have to put them (or the whole expression) in single quotes to escape Mp3tag scripting.

$regexp(%title%,'(.) [(.)]',$2)


I missed that. I was just about to post that I found out that I needed the single quotes.
most of the searches in the forum for $regexp didn't use the single quote. I found one that did and said "hmm.." and that's when it started working!

And now that I read the full scripting section I see the

Characters with special functionality
[...]    The contents of brackets are displayed only if at least one of the placeholders used inside the brackets has been found.
'    Outputs raw text without parsing. This will output the contained string and ignore all reserved characters. If you want to output this character please use ''.
[]$%    You have to put the single quote around these reserved characters if you want to use them unparsed.
,()    These characters must only be escaped when they are inside a scripting function.

Thanks for the help!


The single quotation marks might be added in the help regarding replace with regular expressions, There,

is stated. This confused me a couple of days ago, when I tried to escape a (.

I filed a bug report, although this is a minor issue only, /t/13247/1.

Your confusion isn't cleared yet. The single qotation mark has not to be added to the characters with special funcitions for regular expressions. It has only a special function at "function scripting"

The "problem" is, that Mp3tag has different scripting languages, which can be combined at some places:

  1. Function scripting:
    Special characters: []$%,()
    Escape with: '

2: Web Sources scripting:
Special characters: "#
Escape with: \

3: Filter scripting:
Special characters: "
can not be escaped

4: Regulare Expressions scripting:
Special characters: . | * ? + ( ) { } [ ] ^ $.
Escape with: \

Regular Expressions can be combined with the three other scripting "enviroments". But you only have to care about single quotes or the double function of [] if you combine it with Function scripting.

Okay, thanks for giving me advice! It's hard to understand when consulting single sections of MP3Tag's help (at least for me), but I don't mean to be critical! If I could, I would come up with constructive feedback.