IPB

Welcome Guest ( Log In | Register )

> Notice!

Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.

Also make sure you've read the Forum Guidelines before posting in this forum.

 
Reply to this topicStart new topic
> Probelm with regexp..., Can't escape [
Jim B
post Mar 20 2012, 16:18
Post #1


Member


Group: Members
Posts: 2
Joined: 20-March 12
Member No.: 16224
Mp3tag Version: 2.50



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.
Go to the top of the page
 
+Quote Post
pone
post Mar 20 2012, 16:47
Post #2


Member


Group: Full Members
Posts: 1571
Joined: 15-March 09
From: Germany
Member No.: 9103
Mp3tag Version: 2.50



ZITAT(Jim B @ Mar 20 2012, 16:18) *
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
http://help.mp3tag.de/main_scripting.html
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)
Go to the top of the page
 
+Quote Post
Jim B
post Mar 20 2012, 16:58
Post #3


Member


Group: Members
Posts: 2
Joined: 20-March 12
Member No.: 16224
Mp3tag Version: 2.50



QUOTE (pone @ Mar 20 2012, 11:47) *
You are missing the Mp3tag Scripting Syntax
http://help.mp3tag.de/main_scripting.html
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)

Thanks!

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
CODE
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!

Jim
Go to the top of the page
 
+Quote Post
LosMintos
post Mar 21 2012, 16:15
Post #4


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



The single quotation marks might be added in the help regarding replace with regular expressions, http://help.mp3tag.de/options_format.html#regexp. There,
ZITAT
All characters except . | * ? + ( ) { } [ ] ^ $.
These characters are literals when preceded by a "\".
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, http://forums.mp3tag.de/index.php?showtopic=15381.
Go to the top of the page
 
+Quote Post
pone
post Mar 21 2012, 17:33
Post #5


Member


Group: Full Members
Posts: 1571
Joined: 15-March 09
From: Germany
Member No.: 9103
Mp3tag Version: 2.50



ZITAT(LosMintos @ Mar 21 2012, 16:15) *
The single quotation marks might be added in the help regarding replace with regular expressions, http://help.mp3tag.de/options_format.html#regexp. 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, http://forums.mp3tag.de/index.php?showtopic=15381.


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:
http://help.mp3tag.de/main_scripting.html
Special characters: []$%,()
Escape with: '

2: Web Sources scripting:
http://help.mp3tag.de/main_online.html
Special characters: "#
Escape with: \

3: Filter scripting:
http://help.mp3tag.de/main_filter.html
Special characters: "
can not be escaped

4: Regulare Expressions scripting:
http://help.mp3tag.de/options_format.html#regexp
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.

This post has been edited by pone: Mar 26 2012, 16:58
Go to the top of the page
 
+Quote Post
LosMintos
post Mar 26 2012, 14:55
Post #6


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



ZITAT(pone @ Mar 21 2012, 18:33) *
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:
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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd May 2013 - 18:14