Title Case to Camel Case

From EggeWiki
Revision as of 02: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)
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>