This challenge looks like a fun experiment in building a simple rules-based validator.
- A name is a sequence of terms separated by a space. It must have at least 2 terms. The last term must be a word.
- A term is either an initial or a word.
- An initial is a single capital letter followed by a period.
- A word is a capital letter followed by one or more letters (upper or lower case).
Write a function that checks whether a string is a valid name.
- George R. R. Martin
- Abraham Lincoln
- J. R. Bob Dobbs
- H. G. Wells
- J R Tolkien (no periods)
- J. F. K. (must end in word)
- Franklin (must have at least two terms)
Please submit your solutions as comments on this gist.