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 © 2022 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion and http://snippets.bentasker.i2p
hit counter