Author Topic: Full regex functionality for virtul tags.  (Read 6444 times)

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
This is a request to have regex support within virtual tags.
Not a 'simple' true/false implementation, but full-fledged, so you can use more precise rules to create specific filtered, and/or replaced output.

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
I'm not quite sure what you mean, but definitely +1 for a regex version of Replace.  Where else do you imagine it being used?
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
I'm not quite sure what you mean, but definitely +1 for a regex version of Replace.  Where else do you imagine it being used?

I tried to describe it briefly, and it seemed so clear in my own head ;-)

I am asking for it, specifically because I am currently running into some problems deriving 'Work, Parts, Acts, etc. from the titles of classical tracks.
http://getmusicbee.com/forum/index.php?topic=20209.msg123553#msg123553

For this I am making use of the delimiters , : - such a title should contain for this purpose.
My current virtual formulas seem to work quite well if these delimiters are present and occur not more than once each.
But as soon as a title contains more than one of those delimiters (such as in names, or longer and/or more refined or complicated names or sub-titles etc.) my formulas get confused rather easily.
I think it would be easier to tackle that problem using regex.

And it would probably also be easier to leave out parts of information from the title (or any other tag) that you don't want ending up in the virtual tag.
With the current options, you'll sort of have to reverse your thinking into: "to get the required output, what do I need to leave out first, what do I need to leave out next, what next, repeat, until you finally end up with the part you do want to end up with.
This also requires lots of nested commands, which tend to quickly fry my brain.
With regex the thought-process would be more humanoid-logical for this: "what do I want to have displayed?".

And finally, such a regex can very easily be tested on it's working by means of a regex tester. You will immediately and conveniently be able to see the result of anything you do with a regex.
The way of experimenting with formulas within MusicBee is no fun. As soon a you make the tiniest mistake in a formula, the tag panel will only say something like 'cannot parse', and you won't be able to see results that easy.
Last Edit: February 04, 2017, 09:09:59 AM by hiccup

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
That all makes sense, but which functions specifically would it apply to?

Any function that doesn't hook onto specific text in the tag wouldn't have any use for Regex.  So that gives us $Replace, $Split, and maybe $If (But $If is already covered by $IsMatch).  Am I overlooking anything?
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
The problem for me to oversee this and make some more specific suggestions or requests, is that there only is some vague hint that some regex functionality might be present for virtual tags, and that it might be used by using $IsMatch, and that that might give a True/False output.
Nobody confirmed this, nobody showed a working example.
I would like regex functionality that can give output that contains specific parts from a tag it sources from. Not just having an output saying True/False that will need to be made useful by the existing functions.

It's probably best to wait if Steven chimes in, otherwise we might be discussing and expecting things that can't or will not happen.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34362
i am happy to implement the regex.replace function where it would replace all matching instances in a field

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
Awesome! That'll be a big help, and could be nested with $Split to make that work with a pattern.
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34362
i have added:
Code
RxSplit(<field>,regex,index)
RxReplace(<field>,regex,replace-text)
note that replace-text can be literals or substitutions: https://msdn.microsoft.com/en-us/library/ewy2t5e0(v=vs.110).aspx

http://musicbee.niblseed.com/V3_1/MusicBee31_Patched.zip

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
That's great!
But.... I'm not sure I understand the working/syntax yet though.
Could you (or somebody else who is already getting this) perhaps give two quick examples of this would look like in real-life?

For example on a <Title> being:
"John ft. Mary (live)"

One example for what the virtual tag would look like if you want to have the output being just: (live)
and another one for what it would look like if you would want to only replace 'ft.' by 'feat.'

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34362
i plan to enhance the virtual tag template editor so you can get a preview, so that should make things a bit better

CritterMan

  • Sr. Member
  • ****
  • Posts: 556
  • Now with FiiO M11!
i plan to enhance the virtual tag template editor so you can get a preview, so that should make things a bit better

 :)
Home Desk ~ MB 3.3 Portable • Questyle CMA400i (ASIO) • Sennheiser HD 660S (balanced) / Audeze EL-8 Closed Back / Fostex TR-X00 Ebony • Teac AI-101DA • Jamo C93 + Dayton Audio SUB-1000
Work Desk ~ MB 3.3 Portable / Tidal • SMSL SU-8 v2 • Nobsound NS-05P • THX AAA 789 • Sennheiser HD 58X (balanced)
OTG ~ FiiO M11 • Audiofly AF180 / B&O H6

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
i plan to enhance the virtual tag template editor so you can get a preview, so that should make things a bit better

Wow, that would be really fantastic.

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
That's great!
But.... I'm not sure I understand the working/syntax yet though.
Could you (or somebody else who is already getting this) perhaps give two quick examples of this would look like in real-life?

For example on a <Title> being:
"John ft. Mary (live)"

One example for what the virtual tag would look like if you want to have the output being just: (live)
and another one for what it would look like if you would want to only replace 'ft.' by 'feat.'

For (live), wouldn't the regex be (the terminal $ might be redundant, so it can be omitted)
Code
(^.*)(\([Ll]ive\)$)
Return code
Code
$2

For Foo ft Foo -> Foo (feat. Foo)
Code
(^.*)([Ff]eaturing|[Ff]t\.|Feat\.)(.*$)
Return code
Code
$1\(feat\.$3\)

For simply ft. (or Ft.) -> feat.
Code
[Ff]t\.
Return code
Code
feat\.

On a side note, I held my tongue on this wishlist thread since nothing happened (for some reason or another I'm not privy to) the last few times I made this request.  I just hoped that it would be incorporated finally and it appears that Steven did it.  I'm glad to see MB incorporating this feature and I'm looking forward to playing around with it.
Last Edit: February 05, 2017, 09:04:12 PM by theta_wave

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
Early teething problems with $rxreplace.  The following code variations disappear after hitting save despite MB validating them as "OK".

Code
$RxReplace(<Title>,"(^.*?)(\: )(.*$)",$3)
Code
$RxReplace(<Title>,(^.*?)(\: )(.*$),$3)

Below returns the following, doesn't work and disappears when trying to use it in the thumbnail browser: $RxReplace(<Title>,""("^.*?")""("\:" "")""(".*"$"")"","$3")
Code
$RxReplace(<Title>,"(^.*?)(\: )(.*$)","$3")
Last Edit: February 05, 2017, 09:05:17 PM by theta_wave

hiccup

  • Sr. Member
  • ****
  • Posts: 7884
On a side note, I held my tongue on this wishlist thread since nothing happened (for some reason or another I'm not privy to) the last few times I made this request.  I just hoped that it would be incorporated finally and it appears that Steven did it.  It is good to see MB incorporating this feature finally and I'm looking forward to playing around with it.

I can't tell you, but I am pretty sure this sort of thing is a matter of time (and timing). Now was probably a good moment for S. to invest his time and effort in it.
And thanks for your reply and feedback, that will be extremely helpful for me (and others) getting this to work.