regular expression help needed


#1

hey guys im in dire need of assistance.

what i would like to know is how to turn this...
toby dreher - pueblo (holger flinsch remix)

into this...
toby dreher - pueblo -- holger flinsch remix

and vice versa

cheers, marty :wink:


#2

From: "toby dreher - pueblo (holger flinsch remix)"
To: "toby dreher - pueblo -- holger flinsch remix"

Action: Format Value
e. g.
$regexp('toby dreher - pueblo (holger flinsch remix)','^(.+?) - (.+?) ((.+?))$',$1 - $2 -- $3)

From: "toby dreher - pueblo -- holger flinsch remix.mp3"
To: "toby dreher - pueblo (holger flinsch remix)"

Action: Format Value
e. g.
$regexp('toby dreher - pueblo -- holger flinsch remix','^(.+?) - (.+?) -- (.+?)$',$1 - $2 ($3))

DD.20081211.1130.CET


#3

thank you so much DetlevD for the quick reply :wink: but it seems i have wasted your time somewhat :frowning:

having looked at the string i realise now the specificity i failed to clarify...

i.e , i would like for it to be a generalised string that doesnt necessarily pertain to those particular words, simply something that is universally applied to anything before and after the - , and -- , and anythign inbetween the ( ) , with no set number of words or characters , just anythign and everythign that may or may not be there.

so with these examples to be precise....

from: xxx xxxxxxx - xxxx -- xxx xxxx xxxxxx xxx
to: xxx xxxxxxx - xxxx (xxx xxxx xxxxxx xxx)

AND

from: xxxx - xxxxxx xxx (xxxx xxx xxxxxx)
to: xxxx - xxxxxx xxx -- xxxx xxx xxxxxx

i apologise once again, and would really appreciate your help

cheers, marty :wink:


#4

It seems so <_< because your second example is equivalent to your first example.

From: "xxx xxxxxxx - xxxx -- xxx xxxx xxxxxx xxx"
To: "xxx xxxxxxx - xxxx (xxx xxxx xxxxxx xxx)"
$regexp('xxx xxxxxxx - xxxx -- xxx xxxx xxxxxx xxx','^(.+?) - (.+?) -- (.+?)$',$1 - $2 ($3))

From: "xxx xxxxxxx - xxxx (xxx xxxx xxxxxx xxx)"
To: "xxx xxxxxxx - xxxx -- xxx xxxx xxxxxx xxx"
$regexp('xxx xxxxxxx - xxxx (xxx xxxx xxxxxx xxx)','^(.+?) - (.+?) ((.+?))$',$1 - $2 -- $3)

Your response shows that you are not familiar with the philosophy of Mp3tag and Regular Expressions in general. What did I do for you? I took your example and built an adapted regex pattern and tried the regex with your example string (which I assumed to be a generalized example string that fits to your needs) to demonstrate that the regex pattern does what it should do.

Now it is your work to adapt the proposal to your special application: replace the 'what'-parameter of the $regex() function with the content from the tagfield of your choice; I assume that you can use the tagfield placeholder %TITLE% (your example looks like this case) or, may be, you want to use the content from the system tagfield _FILENAME, which can be adressed by the placeholder %_FILENAME%.

If you want to combine both regular expressions into a single one expression please study regular expressions in depth. There might be a chance to do that, but it will take more time than a tea break, which I've invested into your request.

If your example relies on the filename string you may try 'filename to tag' and 'tag to filename' options from Mp3tag's converter section. Try to understand the meaning of a delimiter character resp. a character sequence as a field separator.

DD.20081212.0535.CET


#5

i apologise for my ignorance in advance, i have little to no understanding of the code and how to use it...

i attempted to add that string to a custom regular expression command, replacing the exampled name with %_FILENAME% and it doesnt work. im not sure if thats what u asked me to do...

there is a "replace matches with:" line that i dont know what to do with.

id be greatly appreciative of u to treat me like a complete noob on the subject and to show me ecactly how to set it up correctly if possible.

cheers again, marty :wink:


#6

See regular expression help needed
I've suggested to use the scripting function $regexp() together with the action 'Format value'.

DD.20081214.1105.CET


#7

DetlevD, you are an absolute legend!

thankyou so much for your time and patience, everythign works perfectly.

cheers, marty :wink:


#8

Thank you for your nice feedback.
I am also glad that it works for you, can drink my tea now undisturbed.

DD.20081215.0941.CET