Skip to content

Instantly share code, notes, and snippets.

@aaronthorp
Created June 26, 2015 01:28
regex_search.js
function buildRegExp(searchText) {
var words = searchText.trim().split(/[ \-\:]+/);
var exps = _.map(words, function(word) {
return "(?=.*" + word + ")";
});
var fullExp = exps.join('') + ".+";
return new RegExp(fullExp, "i");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment