Context
I want to generate all characters that can be generated by:
- opening note pad
- pressing a single key on the keyboard
- holding shift + pressing a single key on the keyboard
What I currently have:
(concat (range (int \a) (int \z))
(range (int \A) (int \Z))
(range (int \0) (int \9)))
then manually appending more characters like ~!@#$%^&*()_+{}|:”<>?,./;'[]\
Question
Is there a more elegant way of doing this?
Edits
Yes, I’m referring to US Qwerty keyboard.
If you look at a US ASCII chart, it seems that all the characters you want are within
(range 33 127). So the simplest way to get a sequence of all those characters is to convert that range to characters.But if you are trying to validate that a string contains only those characters, have a function like:
Then you can use it with
every?to validate a string: