Camel Case
August 29, 2017
Some programmers write variable names in camelCase, each word starting with a capital letter, while other programmers separate words with underscores like_this.
Your task is to write programs that convert between the two forms. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
This gives a slightly different answer (when the first character is upper case as it doesn’t prefix it with an underscore…;
In Python. Probably the regex split can be improved to handle multiple capitals, but I did not manage yet.
Why would anyone want to convert to the underscore format? Although this may be a very interesting exercise programmatically, I find its use case quite limited.
@Zack: Underscore case is the convention in some languages, including Oracle SQL and PL/SQL which I use every day in my regular job.
On Tue, Aug 29, 2017 at 9:08 AM, Programming Praxis wrote:
>
A shorter version of the split function.
Solution for ASCII characters in Ruby.
The test…
Outputs:
Solution for ASCII characters in Ruby. (Posting again without Emojis)
The test…
Outputs:
@programmingpraxis fell free to delete my previous post.