Logan
March 31, 2004, 10:59pm
1
Ok, need a little help here....
First off, anyone know of a good Regular Expression tutorial ? I'd like to learn how to do this myself...
While I dig around for one, would appreciate it if someone could enlighten me as to how I do the followig :
search for x-x and replace with x - x where x is any character
change the string track - artist - title (pres artist2) (mix_name) to track - artist pres artist2 - title (mix_name)
Fun facts about the second one :
'track' and '(mix_name)' are optional
'pres' may be 'feat' or 'vs.' - but all files will have one of the three
I would
greatly appreciate any assistance offered.
dano
April 1, 2004, 6:39am
2
1:
(.)-(.)
$1 - $2
2:
^(\d{1,2}\s-\s)?(.)\s-\s(. )\s((.))(\s(. ))?
$1$2 $4 - $3$5
Mp3tag helpfile is good
Logan
April 5, 2004, 7:27pm
3
Thanks for the help d4n0, but the second one didn't quite work.
Your suggestion resulted in :
track - artist mix_name - title (pres artist2)
when I am looking for :
track - artist pres artist2 - title (mix_name)
When I broke the results down into $1 - $2 - $3 - $4 - $5, it does not appear to be seperating the string title (pres artist2) into two compenents.
I checked the help file as you suggested, but apparently I am daft...
Any more suggestions ?
dano
April 5, 2004, 8:29pm
4
i have no clue why title (pres artist2) is always together
Check the greedyness of the repeats in the parenthesis part. The regular expression
^(\d{1,2}\s-\s)?(.)\s-\s(. )\s((.?))(\s(. ?))
should work.
Best regards,
~ Florian
dano
April 6, 2004, 7:43am
6
it does not work when there is no (mix_name) at the end
Oh yes, you're right! I've changed all repeats to be non-greedy in your regular expression and now it should work for both cases.
^(\d{1,2}\s-\s)?(.?)\s-\s(. ?)\s((.?))(\s(. ))?
$1$2 $4 - $3$5
Best regards,
~ Florian
dano
April 6, 2004, 1:10pm
8
awesome, yes seems to be fine now
and i gotta find out what greedyness exactly is
You can translate greedyness with "Gierigkeit". Greedy (standard) repeats are eating as much characters as possible - the non-greedy ones (those with the question mark after the repeat character) don't
~ Florian