The regex /(.).*\1|\d|[-\s]/i
is not able to detect that the word "thumbscrew-japingly" is an isogram because the regex pattern is designed to match any character that is repeated, any digit, or any hyphen or whitespace character.
In the word "thumbscrew-japingly", each letter is only used once, and there are no repeating characters. Therefore, the regex pattern does not match any part of the word, and it cannot detect that the word is an isogram.
If you want to check if a word is an isogram using Ruby, you can use the following code snippet:
main.rb182 chars8 lines
In the above code, we first convert the word to lowercase and then split it into an array of characters. We remove the hyphen and whitespace characters from the array. If the size of the resulting array is equal to the size of the array after removing duplicate characters, then the word is an isogram.
The output of the code snippet above is true
, indicating that "thumbscrew-japingly" is indeed an isogram.
gistlibby LogSnag