CamelCase in AWK

Example for versions gawk 3.1.6

Variable 0ドル stores the whole string read (as opposed to variables 1ドル, 2ドル etc. which store fields of the record). split splits the string into fragments which are separated with matches to the regular expression and writes the result to the array words. After this each element of the array is converted to correct case using functions substr, toupper and tolower.

{ text = 0ドル;
 split(text, words, /[^a-zA-Z]+/);
 for (i=1; i<=length(words); i++) {
 res = res toupper(substr(words[i],1,1)) tolower(substr(words[i],2));
 }
 print res
}

AltStyle によって変換されたページ (->オリジナル) /