I want to see a print out of the character layout in ruby ( sorry I don't know the lexicon for what I am asking)
It is something like
abcdefghijklmnopqrstuvwxyzaabbcc..zz
then it goes to
ABCDE....ZAABBCC
etc
Asked
Active
Viewed 81 times
0

Pedro Castilho
- 10,174
- 2
- 28
- 39

CJ Jean
- 971
- 1
- 8
- 10
-
I didn't understand when do uppercase come into play? First single letter lower case, then double letters lower cause, then single upper, double upper? a-z aa-zz A-Z AA-ZZ, and then? aaa-zzz aaaa-zzzz AAA-ZZZ AAAA-ZZZZ? – Luan Nico Apr 20 '17 at 20:10
-
The looping will not ever go from lower case to upper case see [String#next](https://ruby-doc.org/core-2.2.0/String.html#method-i-next) *Excerpt: "...incrementing a letter results in another letter of the same case....If the increment generates a “carry,” the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary."* So it will go something like a-z aa-az ba-bz.....aaaaaaaa-azzzzzzz, etc. – engineersmnky Apr 20 '17 at 20:26
2 Answers
1
It sounds like you want to generate a pattern similar to how most spreadsheet software (such as Excel) name their Columns.
This question asks exactly that:
How to convert a column number (eg. 127) into an excel column (eg. AA)
It has some great answers you can check out.
What makes your question different from the excel pattern is that you want to account for lower case letters as well.
Modifying any of those solutions to account for 52 letters instead of just 26 should be trivial.

Community
- 1
- 1

Aditya Mukherji
- 9,099
- 5
- 43
- 49
0
You can print from a
to zz
with:
('a'..'zz').to_a.join
=> 'abc ... xyzaaabac ... zxzyzz'
And from A
to ZZ
with:
('A'..'ZZ').to_a.join
=> "ABC ... XYZAAABAC ... ZXZYZZ"
Also interesting is convert numerical to char:
(0..255).each {|e| p e.chr}

Alejandro Babio
- 5,189
- 17
- 28
-
This is interesting but I am looking for the sequence that ruby has. For example " ".next is "!" – CJ Jean Apr 21 '17 at 20:19
-
So where is a visual print out of all the characters?and the sequence they have in ruby – CJ Jean Apr 21 '17 at 20:20
-
starting with (space) `" "` to `"z"` here is the sequence I get:" !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz" – CJ Jean Apr 21 '17 at 20:21
-
[String#next](http://ruby-doc.org/core-2.3.3/String.html#method-i-next) works on current char, as defined in the docs (yes `" ".next => "!"`, and also `"9".next => "10"`). I'm afraid that the sequence that you are looking for does not exist. You will found more information in [this](http://stackoverflow.com/a/39460360/4151953) answer. Well, it can exist as result of a monkey-patch or some new class created with that behaviour. – Alejandro Babio Apr 22 '17 at 00:45
-
Thanks Alejandro, I've seen it. I just don't know where and can't find it in my bookmarks because I don't know what lexicon to use to search for it. Thanks for the link It may be the ASCI code for the ruby version installed. – CJ Jean Apr 23 '17 at 23:13