Trim whitespace from beginning of string



Published: 2017-06-03 10:29:42 +0000
Categories: LUA,

Language

LUA

Description

A basic implementation to strip leading whitespace from a string lua

Similar to

  • PHP: ltrim()
  • Python: lstrip()

Based On

Snippet

function ltrim(s)
  return s:match'^%s*(.*)'
end

Usage Example

local a = ' abcde fg    '
print( a )
print(ltrim(a))

Keywords

ltrim, lstrip, trim, whitespace, leading, remove,

Latest Posts


Copyright © 2019 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, yr4pnhounvdybotb.onion and snippets.6zdgh5a5e6zpchdz.onion