Some classic rock from time to time is really not a bad idea. Labels, however, really like making some extra money. That’s why there are millions of songs being remastered and remixed. When done well, that’s great! Bringing some new fidelity to old classics is a great pursuit.

However most producers just really like to put the audio levels to max. Losing most of the dynamics that were designed to be in the tracks on the first place. Ah well. You can read more about the Loudness War on Wikipedia if you like.

Let’s take a look at the regex I’ve added to my Now Playing widget script.

The stripping of ‘ - Remastered’, ‘(mono)’ and more.

Spotify’s uploaders like to present the song titles with this extra piece of information. Whether when it was remastered in a certain year, or that the mixed stereo in the year 2001. In the case of displaying what song I am listening to: I don’t care for that.

I’ve used a regular expression to get rid of the things I don’t care for. I have collected a few test pieces to match with. 60s rock seems to be popular subjects to remastering. Here are my subjects:

  • My Generation - Stereo Mix
  • Born To Be Wild - Single Version
  • Surf City - Remastered 1990 / Stereo Mix
  • Turn! Turn! Turn! (To Everything There Is A Season) - version 1 - take 2; Previously Unissued

You can’t top that last one. It seems we need to look for blank + hyphen ánd blank + opening bracket and remove what follows. For the first case, the regex is: - (.*). Which practically means “search for blank+hyphen and match everything after that”.

For the second case we look for the bracket: \((.*) Which means: “search for the blank+bracket and match everything after that”. An OR expression is done with the | symbol. Resulting in the following, working regex:

 \((.*)| - (.*)

Test it out here if you like. Now it is just the question to pass the song title through the regex, match the pattern and replace it with nothing. Easy enough:

var cleansongname = \((.*)| - (.*)/g, "");

Resulting song titles after regex

And now the songs titles look much better:

  • My Generation
  • Born To Be Wild
  • Surf City
  • Turn! Turn! Turn!

Ah. Much better. The following is the javascript I ended up using for my desktop specific website widget. Make sure you check out that other note I wrote about the Now Playing widget.

$(document).ready(function() {
  $.getJSON("", function(data) {
      var html = '';
      var counter = 1;
      var cleansongname = '';
      $.each(data.recenttracks.track, function(i, item) {
          if(counter == 1 && item['@attr'] !== undefined && item['@attr'].nowplaying) {
              cleansongname = \((.*)| - (.*)/g, "");
              html += '<div class="musicVisualizer"><span></span><span></span><span></span></div><span class="musicLabel">Geffrey is now playing: </span><br><span><strong>' + cleansongname + '</strong><br> by ' + item.artist['#text'] + '</span>';