Title Case to Camel Case

From EggeWiki
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>