Skip to content
lsl.devlsl.devLSL Dev

User:Peter Stindberg/strCapitalize

Wiki description

Created by Peter Stindberg, this function will take a string as input and return the string with the first letter of each word capitalized and all the other letters in lowercase.
string strCapitalize(string str)
{
    list phrase = llParseStringKeepNulls(str, [" "], []);
    integer i;
    for (i = 0; i < llGetListLength(phrase) ; i++) {
        phrase = llListReplaceList(phrase, [llToUpper(llGetSubString(llList2String(phrase,i),0,0)) + llToLower(llGetSubString(llList2String(phrase,i),1,-1))], i, i);
    }
    return llDumpList2String(phrase, " ");
}

Return value notes

Returns a string with each word capitalized.

Caveats

Will fail with acronyms since all letters but the first will be turned to lowercase.
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.