Skip to content

Instantly share code, notes, and snippets.

@erictleung
Created November 12, 2015 07:41
Show Gist options
  • Save erictleung/3276ed76bd90278e23ce to your computer and use it in GitHub Desktop.
Save erictleung/3276ed76bd90278e23ce to your computer and use it in GitHub Desktop.
Checks if given string is a palindrome after removing punctuation (e.g. back and forward slashes, commas, periods, colons, semicolons, dashes, spaces)
function palindrome(str) {
tempStr = str.replace(/(\.|,|\s|_|:|;|\(|\)|\/|-)/g, "").toLowerCase();
return tempStr.split("").reverse().join("") == tempStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment