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.
![]() ![]() |
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 |
|
|
|
Jun 2 2011, 07:22
Post
#2
|
|
![]() Member Group: Full Members Posts: 4129 Joined: 26-May 06 From: Wuppertal, Germany, Planet Earth Member No.: 3194 Mp3tag Version: 2.54 |
... 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 ♥ |
|
|
|
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. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 25th May 2013 - 11:51 |