Invert GMLscripts.com

string_ltrim

Returns given string with whitespace stripped from its start. Whitespace is defined as SPACE, LF, CR, HT, VT, FF. A string of characters to be trimmed may be optionally supplied.

//  string_ltrim(str, trim)
s = string_ltrim("123");                //  "123"
s = string_ltrim(" 123");               //  "123"
s = string_ltrim("123 ");               //  "123 "
s = string_ltrim(" 123 123 ");          //  "123 123 "
s = string_ltrim(" \a 123");            //  "\a 123"
s = string_ltrim("\t\r\n123\f \v");     //  "123\f \v"
s = string_ltrim("123456789", "1289");  //  "3456789"
string_ltrim(str, trim)
Returns given string with whitespace stripped from its start.
COPY/// @func   string_ltrim(str, trim)
///
/// @desc   Returns given string with whitespace stripped from its start.
///         Whitespace is defined as SPACE, LF, CR, HT, VT, FF. A string
///         of characters to be trimmed may be optionally supplied.
///
/// @param  {string}    str         string of text
/// @param  {string}    trim        characters to trim, optional
///
/// @return {string}    trimmed string
///
/// GMLscripts.com/license

function string_ltrim(str, trim=" \n\r\t\v\f")
{
    var l = 1;
    var r = string_length(str);
    while (string_pos(string_char_at(str, l), trim)) {
        l++;
    }
    return string_copy(str, l, r - l + 1);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw