Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) > HOW-TO's

How to remove leadin of traling spaces from a string

(1/1)

satya:
Hi


I want to remove all blank spaces from a string.

for ex: local Abc="              Trial test"

how to remove the leading spaces wich will indeed make the var Abc to hold value "Trial test"

thanks

HaArD:
This will actually strip leading and trailing spaces.


--- Code: ---    function trim (s)
      return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
    end

--- End code ---

satya:
Thanks buddy

Thats great help

Navigation

[0] Message Index

Go to full version