I’m working on the “Bob” exercise on the Elixir Track in Exercism.
I am testing for uppercase letter with this simple check: c in ?A..?Z, but one of the test cases requires that Unicode uppercase letters be handled.
I’ve Googled a little bit and couldn’t found anything useful. An answer on Stackoverflow suggested to use regular expression on the string. I wonder if there’s anything as simple as Unicode.is_upper? in the standard library.
When I first solved Bob, I did so entirely with the Regex module. One of the comments my mentor made, was that, although Bob can be solved many ways, the intent of this exercise (on the Elixir track) is to get you familiar with the String module. I was encouraged to return to the String module, and solve the exercise without using any regexes at all. The solution I came up with turned out to be much more elegant than the regex solution, and indeed required only functions from String.
Here is a hint to get you started: Under what conditions would the uppercase version of a string be the same as the original? Are there other relationships like this you can leverage?
Q: Does uppercasing of a string eliminate all of the lowercase letters in it?
A: No. Some letters (notably those in the IPA block) have no matching case equivalent. As a result, uppercasing a string may not eliminate all of the lowercase letters in it.