Warcraft III resources & community, 2003–2006 · archived

StringTrimRight

not rated
Submitted by PepparText Parsing0 downloads
Removes all spaces at the end of string s.

Source

function StringTrimRight takes string s returns string
    local integer i = 0
    local integer l = -1
    local string c
    if s == null or s == "" then
        return ""
    endif
    loop
        set c = SubString( s, i, i + 1 )
        if c == "" then
            exitwhen l < 0
            return SubString( s, 0, l + 1 )
        elseif c != " " then
            set l = i
        endif
        set i = i + 1
    endloop
    return ""
endfunction

Comments

0

No comments.