function countNumMatches(contents, queryExpr) {
    if (!contents) {
        return 0;
    }
    var matches = contents.match(queryExpr);
    return matches ? matches.length : 0;
}
Counts the number of matches matching the queryExpr in the given contents
@param   {String} contents  The contents to search on
@param   {Object} queryExpr
@return {number} number of matches