Jump to content

Title Case to Camel Case

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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>