课程: R Code Challenges: Data Science
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Password validator
- [Instructor] Identifying a palindrome is a quick and easy way to test your knowledge of regular expressions and string manipulation. It's a fairly easy challenge, but let's take a look at how to solve it. This requires the creation of a function called is.palindrome, and in the code window, you can see my code to solve this problem. If I define is.palindrome, and I give it a value, I'll say, "Mark", it should return false, because that word does not look the same forward as backward. If I give it a true palindrome, let's say "Race Car", I should return true. What's even more interesting is if I give it a phrase, something like, "Madam, I'm Adam," you'll see that I have uppercase, lowercase, and punctuation, but it's still a palindrome. So there are several cases we need to filter out and change in order to identify palindromes correctly. In line two, three, and four of the code in the upper right hand corner, you can see that I'm filtering this out. The first thing I do in line two…