By Daniel · December 26, 2008
Converts the first character of each word in a string to uppercase
// string_ucwords(str)
// Converts the first character of each word in a string to uppercase
var in, out, pos, final;
in = argument0;
out = '';
final = false;
while (!final) {
pos = string_pos(' ', in);
if (pos == 0) { // no more spaces
pos = string_length(in);
final = true;
}
out += string_upper(string_char_at(in, 1)) + string_copy(in, 2, pos - 1);
in = string_delete(in, 1, pos);
}
return out;
Categories: String handling
There are no comments to display.
You must be signed in to post comments.