JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://underscorejs.org/underscore-min.js"></script>

JavaScript

var exerciseName = "Supine Shoulder Circumduction #today With Medicine Ball #foobar I2015-05-31T13:48:18.811Z";


console.log("Log1: " + exerciseName);


var toLowerCase = function (w) {
    return w.toLowerCase();
};

var words = exerciseName.split(/\s/); // split by whitespace chars, not word boundaries
words = _.map(words, toLowerCase);


console.log("Log 2: " + words); // array of lowercase words
// console.log("Log 2: " + words.join(" ")); // join with spaces to make it look like a sentence


var stopWords = ["the", "in", "and", "with", "on"]

var filtered_words = _.filter(words, function (w) {
    return w.match(/^\w+$/) && !_.contains(stopWords, w);
});

console.log("Log 3: " + filtered_words); // doesn't contain stop words and any other non alphanumeric values



var no_stop_words = _.filter(words, function (w) {
    return !_.contains(stopWords, w);
});

console.log("Log 3a: " + no_stop_words); // only filters stop words. hashtags and dates are still present


var hashtags = _.filter(words, function(word) {
    return word.indexOf("#") === 0;
});

console.log("Log 4: " + hashtags);