Standard trim, rtrim, and ltrim functions to remove leading and trailing whitespace characters.

Language: 
Dark Basic Pro
Code: 
function trim(str as string)

  str = rtrim(ltrim(str))

endfunction str

function ltrim(str as string)

  local char as dword
  local length as dword

  length = len(str)

  repeat
    inc char
    if asc(mid$(str, char)) <> 9 and asc(mid$(str, char)) <> 32
      str = right$(str, length - char + 1)
      exit
    endif
  until char > length

endfunction str

function rtrim(str as string)

  local char as dword
  local length as dword

  length = len(str)
  char = length

  repeat
    if asc(mid$(str, char)) <> 9 and asc(mid$(str, char)) <> 32
      str = left$(str, char)
      exit
    endif
    dec char
  until char = 0

endfunction str
4.666665
Average: 4.7 (3 votes)