Trim
From Director Online Wiki
on trim(str, charlist) -- function.trim.php (http://us2.php.net/manual/en/function.trim.php)
--## If the function was called without a list of Characters to trim, default to whitespace if (NOT stringP(charlist)) then charlist = " "&TAB&numToChar(10)&RETURN&numToChar(0)&numToChar(11) end if --## Make sure the input string is not empty if str.length > 0 then --## Remove leading characters, if present repeat while (offset(char 1 of str, charlist)) delete char 1 of str if str.length > 0 then next repeat else --## The string is empty return str end if end repeat if str.length > 0 then --## Remove trailing characters, if present repeat while (offset(the last char of str, charlist)) delete the last char of str if str.length > 0 then next repeat else --## The string is empty return str end if end repeat else --## The string is empty return str end if return str else return str end if
end --[[User:jkramlich|jkramlich]] 14:22, 06 Sep 2006 (MDT)