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
> Problem with Sets in $regexp
TAC109
post Jun 2 2011, 02:09
Post #1


Member


Group: Members
Posts: 4
Joined: 31-May 11
From: New Zealand
Member No.: 14565
Mp3tag Version: 2.49



I'm having a problem with $regexp when I use a set (e.g. "[\w\s]" or "[^\\]") in a regular expression.

My music is structured with the genre as the 2nd directory after root
e.g. S:\Tom\Rock\Genesis etc\Mike & The Mechanics\1990 Interview\01 Mike Rutherford.mp3

I've set up an action group with a Format Value entry, Field GENRE,
Format String: $regexp(%_folderpath%,^.{3}\w+\\(\w+)\\.+$,$1)

This works correctly, returning 'Rock', but it only handles single words in the first directory name. When I change it to
"$regexp(%_folderpath%,^.{3}[\w\s]+\\(\w+)\\.+$,$1)" it returns the complete %_folderpath%

The preferable solution "$regexp(%_folderpath%,^.{3}[^\\]+\\(\w+)\\.+$,$1)" also returns the complete %_folderpath%

Am I doing something wrong or is there a bug?

TIA

This post has been edited by TAC109: Jun 2 2011, 03:03
Go to the top of the page
 
+Quote Post
DetlevD
post Jun 2 2011, 07:22
Post #2


Member


Group: Full Members
Posts: 4909
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.63



QUOTE (TAC109 @ Jun 2 2011, 03:09) *
... Am I doing something wrong ...

Hmm, yes, please study the Mp3tag scripting language in detail, to get to know the exceptions.
Some characters are designed to have a special meaning, e. g. the square brackets.
They need to be escaped when they should be used in their literal meaning in a subsequent language like the Regular Expression Language.

$regexp(%_folderpath%,'^[A-Z]:\\(.+?)\\(.+?)\\.*$','$2')

$regexp(%_folderpath%,'^..\\(.+?)\\(.+?)\\.*$','$2')

$regexp(%_folderpath%,'^..\\.+?\\(.+?)\\.*$','$1')

Each regular expression returns the second foldername from the left side.

DD.20110602.0822.CEST


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
TAC109
post Jun 3 2011, 01:04
Post #3


Member


Group: Members
Posts: 4
Joined: 31-May 11
From: New Zealand
Member No.: 14565
Mp3tag Version: 2.49



Ah yes, the single quotes. When searching the forums I'd seen these in other replies but I hadn't realised their significance.

Many thanks for your response.
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: 2nd September 2014 - 00:25