Author Topic: regex (regular expressions) - open discussion topic  (Read 28846 times)

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
O.k, I'll let go of the idea that (even .net) regex testers will (should) give the exact same result as MusicBee's regex engine.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i will create a very simple application to enter text and see the result


hiccup

  • Sr. Member
  • ****
  • Posts: 7781
http://www.mediafire.com/file/4scm9s52a2z3gub/RegEx.zip

run regex.exe

Great, that's very nice and useful.
This makes it a lot easier to try out and test regexes.


edit,
For the purpose of making this easier to find for other members too, I copied this link in the start post of this topic.
Last Edit: February 28, 2017, 08:52:36 AM by hiccup

alec.tron

  • Sr. Member
  • ****
  • Posts: 752
Heya,
maybe someone who's fluid in regex (and Musicbee's S&R or boroda74s Advance S&R functionalities ) doesn't mind lending a helping hand...?

Based on this suggestion:
https://getmusicbee.com/forum/index.php?topic=20659.msg123990#msg123990
when I tested around it wasn't quite functional as described for me, but I got the replace multi value strings working somewhat... at least for the preview... but not so much for the actual Search&replace operation itself as the replace seems to then re-inject multi value separator ";" as literal string value into the same field and not as a aseparator, so as a practical example to explain the issue, which I am looking for a solution for:

On a file with a multi value genre values of:
Downtempo; Breaks

I want to inject 'Beats' as a second genre value, so, via MB standard Search & Replace tool:
S&R gui input:
"search for:"  
Code
(^.*)(Downbeat)(.*$)
"in field": Genre
"replace with":
Code
$1$2; Beats$3

Results in the seemingly correct preview of:
Downtempo; Beats; Breaks

But, IF I apply the change, I then end up with 2 genre values (and one is a literal string injected after the regex search value...), where there should be 3... so the resulting genre values are:
"Downtempo; Beats"
"Breaks"

So I'm looking to understand how one would need to I re-inject the semicolon separated values correctly via regex/S&R, so it does create its' own genre field correctly...?
So I end up with
"Downtempo"
"Beats"
"Breaks"
genre values on all files ?

Cheers.
c.
Last Edit: May 24, 2017, 05:55:31 AM by alec.tron

boroda

  • Sr. Member
  • ****
  • Posts: 4595
alec.tron, have you tried the same regexes with ASR? my understanding it should work.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
@Steven, is 'genres' (not 'genre') tag is read-only in api?

alec.tron

  • Sr. Member
  • ****
  • Posts: 752
hah!
re:
alec.tron, have you tried the same regexes with ASR? my understanding it should work.
I did not, as I tried it earlier today on a laptop without your ASR installed.

I now just did at home where I have your tagging tools installed, and the same syntax does correctly inject the field delimiter in your Advanced Search & Tag Tools for mp3s as well as flac files!
Awesome!
Guess I'll start creating a fair few presets for ASR ;)
Thanks!
c.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
keep in mind that you can easily modify your own asr presets. you cant modify only preinstalled presets.

minor_glitch

  • Newbie
  • *
  • Posts: 2
Hey everyone, sorry if this is a stupid question or I'm posting in the wrong place.
I'm trying to create a filter for Artist does not match Album Artist.
I was hoping it would be as simple as creating a filter and choosing 'Artist', 'is not', and typing in <Album Artist> but obviously no such luck. I assume this is something I'd have to do through 'match RegEx'.
Can anyone suggest something that might work?

Thanks!

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
Hey everyone, sorry if this is a stupid question or I'm posting in the wrong place.
I'm trying to create a filter for Artist does not match Album Artist.
I was hoping it would be as simple as creating a filter and choosing 'Artist', 'is not', and typing in <Album Artist> but obviously no such luck. I assume this is something I'd have to do through 'match RegEx'.
Can anyone suggest something that might work?

Thanks!
I don't think the solution requires regex.  A virtualtag should work though.

The virtualtag (say "Album artist tag check") formula should look something like this: $If("<Album Artist>"="<Artist>",,blahblah)

Basically, if <Album Artist> equals <Artist>, then the virtualtag will have no value.  Then create a filter or autoplaylist.  For the latter, select the virtualtag you just made and select "has a value".

minor_glitch

  • Newbie
  • *
  • Posts: 2
I don't think the solution requires regex.  A virtualtag should work though.

The virtualtag (say "Album artist tag check") formula should look something like this: $If("<Album Artist>"="<Artist>",,blahblah)

Basically, if <Album Artist> equals <Artist>, then the virtualtag will have no value.  Then create a filter or autoplaylist.  For the latter, select the virtualtag you just made and select "has a value".

Thanks! $If(<Album Artist>=<Artist>,Y,N) seems to have worked!

Mayibongwe

  • Sr. Member
  • ****
  • Posts: 1013
  • Heal The World
I might need this for future reference:
https://getmusicbee.com/forum/index.php?topic=39538.0

-------------

@hiccup, would you consider linking the topic below somewhere in your start-post?
https://getmusicbee.com/forum/index.php?topic=38817.0

I've always found this thread of yours to be easily locatable compared to other regex topics.
So if there's a chance that most people are landing here than elsewhere, I'm sure they'd appreciate knowing about the existence of karbock's thread above.
Favourite song at the moment:   Decode by Paramore

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
@hiccup, would you consider linking the topic below somewhere in your start-post?
https://getmusicbee.com/forum/index.php?topic=38817.0
Good idea, it should have been there already ages ago. Done.

B.T.W.
A while back I played around with creating a custom Google search page that limits itself to searching the MusicBee forum.
I also added some 'keyword magic' that puts the most relevant page(s) at the top.

This is the link:
https://cse.google.com/cse?cx=426af386625354430
If you enter 'regex' as search query, both this topic and karbock's should be at the top.