Title Case to Camel Case

From EggeWiki
Revision as of 01:14, 12 October 2009 by Egge (talk | contribs) (Created page with 'Here's a couple of one liners for converting text to a Camel Case, useful for Java code generation. <geshi lang="bash"> echo "Title Case to Camel Case" | ruby -ne 'puts $_.gsub(…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here's a couple of one liners for converting text to a Camel Case, useful for Java code generation.

<geshi lang="bash"> echo "Title Case to Camel Case" | ruby -ne 'puts $_.gsub(/\b\w/){$&.upcase}.gsub(/ /, "").gsub(/^(.)/){$&.downcase}' titleCaseToCamelCase </geshi>

<geshi lang="perl"> echo "Title Case to Camel Case" | perl -e 'while(<>) { split(/ /); print lcfirst(shift(@_)); print map(ucfirst,@_); }' titleCaseToCamelCase </geshi>