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
Field: ARTIST
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 https://docs.mp3tag.de/scripting
If you are using one of these characters: []$%,()
you have to put them (or the whole expression) in single quotes to escape Mp3tag scripting.
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.
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:
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.