Author Topic: RegEx Help Please  (Read 2999 times)

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9356
I want to take my AutoPlaylists to a new level and I'm pretty sure I need RegEx to accomplish this.  I've looked at the Wiki and from there looked at the RegEx guide, but I'm still pretty clueless.  I'm looking to create an AutoPlaylist where the title contains the words "good " or "bad" and to only select from the genres Rock or Blues.  I'm be very grateful if someone could show me the formula for this and how to set it up.  Note the space character after "good " since I want to exclude words like "goodbye".

Once I see what the formula looks like, I'm sure I can configure the rest of them on my own.

Thanks.
Download the latest MusicBee v3.5 or 3.6 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

redwing

  • Guest
The following paq's note is helpful.

Another solution is to choose match RegEx/i when editing the rule.

In this case, the rule would be: Genre  match RegEx/i  .*Blues.*

  • RegEx is short for Regular Expressions, you can read more about them here for example: http://msdn.microsoft.com/en-us/library/az24scfc.aspx
  • /i is for case-insensitive. Both BLUES and blues will be matched.
  • . (the dot) matches any single character
  • * matches the previous character zero or more times. So .* matches anything, including nothing.

The rule above matches both "Blues Rock", "blues" and "Power Blues".

For your question, you can use bar symbol "|" between the two words as "or" operator. And if you want to find only a whole word, not part of a word, then use word boundary "\b".

good|bad                  (no words need to be whole word)
\b(good)\b|bad         (only good is whole word)
good|\b(bad)\b         (only bad is whole word)
\b(good|bad)\b         (both words are whole words)
Last Edit: July 28, 2014, 03:41:25 AM by redwing

psychoadept

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 10691
You can accomplish this without regex, actually, although the regex solution is way more elegant.

The non-regex solution:

Match all:

Title ... does not contain ... goodbye
Subrule > Match any
Title ... contains ... good
Title ... contains ... bad

Genre ... is any of ... Blues, Rock


Of course, this would miss a track with the title "Bad Goodbye" or something like that.
MusicBee Wiki
Use & improve MusicBee's documentation!

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

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9356
Thank you both for the tips.  I'm sure there will be more questions to follow once I've had some time to play with this and screw it up.   ;)
Download the latest MusicBee v3.5 or 3.6 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here