Created
November 12, 2015 07:41
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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