Node.js examples for Regular expression:Match
Use regex to check string ends
String.prototype.endsWith = function(str) { return (this.match(str + "$") == str); }