help for the script functions such as $regexp:
https://docs.mp3tag.de/scripting
from that link:
$regexp(x,expr,repl):
replaces the pattern specified by the regular expression expr in the string x by repl. The fourth optional parameter enables ignore case (1) or disables the ignore case setting (0). Please note that you have to escape comma and other special characters in expr.
So basically with the function $regexp(x,expr,repl) you can use the action Relace With Regular Expression within other actions such as Guess Values in our case. The "," in the function seperates what you write into the different fields of the action window.
Function:
$regexp(x,expr,repl)
Action:
Field = x
Regular Expression = expr
Replace Matches With = repl
you also need the knowledge from here to about the Guess Values action:
https://docs.mp3tag.de/actions/guess
$regexp(%_filename%,(\d*) (.) (.),$1xxxxx$2xxxxx$3)
So, x is the string which provides the source of the operation. In out case it is the filename. But it could also be a cobination of different palceholders/fields in other cases.
%_filename% = 03 Jefferson Airplane embryonic_journey
$regexp(%_filename%,(\d*) (.) (.),$1xxxxx$2xxxxx$3)
The expression which should be replaced is given here. In our case, it is the whole filename, seperated in different groups.
You can also make expressions which only match parts of the source, in this cases the rest of the source keeps untouched (see here for a example: Need help with RegExp ).
\d* matches a number which is repeated any number of times
.* matches any character repeated any number of times
the spaces are essential, they are the only fix characters here which indicate the seperation of the different matches above.
the parentheses make no difference in the match of the expression. they are only a reference for $1, $2 and $3 later.
So Mp3Tag checks for a sequence of characters in the source which matches \d* .* .*
\d* .* .* with the expample
103 Jefferson Airplane embryonic_journey explained step by step:
\d =
1 is one digit
* =
03 are all digit which come direct after that digit or nothing if there is no more digit.
" " =
" " is one space which comes direct after that digit(s)
. =
J is the character after that space
* =
efferson Airplane are all characters after that character. If there whould come nothing after it would be everything to the end (spaces are also characters). But in our case " .*" comes after it. So it is the longest possible sequence of characters which has still a space after it, i.e. everything before the last space in the source (%_filename%). If i had written \d* .*? .* instead, it .*? would be the shortest possible sequence of characters which has a space after it, i.e. only the first word
" " =
" " is, as sayed, the last space in the source.
. =
e is the character after that space.
* =
mbryonic_journey are all characters after that character, this time without limit, i.e. everything to the end of the filename.
$regexp(%_filename%,(\d*) (.) (.),$1xxxxx$2xxxxx$3)
This is the replacement for the expression. $1, $2 and $3 is what is found in the first, second and thrid parenthesis of the match:
$1 = 103
$2 = Jefferson Airplane
$3 = embryonic_journey
xxxxx is a free choosen seqence of characters which has the purpose of a marker between the desired field values $1, $2 and $3. As the space, which was the marker before, also is part of the artist name, I replaced it which with something which is surely not part of the artist or title name. If the would be a tilte which is for example "fxxxxxck" it would not work.
So
$regexp(%_filename%,(\d*) (.) (.),$1xxxxx$2xxxxx$3)
is without palceholders
$regexp(103 Jefferson Airplane embryonic_journey,(103) (Jefferson Airplane) (embryonic_journey),103xxxxxJefferson Airplanexxxxxembryonic_journey)
103xxxxxJefferson Airplanexxxxxembryonic_journey is the output of our $regexp funtion
And this serves as the Sourceformat for out Guess Values action.
The Guess value Formatstring now makes use of the xxxxx as spliter between the desired field names:
Sourceformat written as function: $regexp(%_filename%,(\d*) (.) (.),$1xxxxx$2xxxxx$3)
Sourceformat as output of the function: 103xxxxxJefferson Airplanexxxxxembryonic_journey
Formatstring : %track%xxxxx%artist%xxxxx%title%
Output of the Formatstring = Output of the Guess Value Action:
TRACK = 103
ARTIST = Jefferson Airplane
TITLE = embryonic_journey