[Geany] geanylua: how to strip \n

Joerg Desch jd.vvd at xxxxx
Tue May 27 08:54:20 UTC 2008


I'm currently playing with geanylua 0.7 and geany 0.14. As you may see, I'm a Lua newbie and this is part of my first script...

I would line to extract the remaining part of a line but without trailing whitespaces and without the \n.

Here a snippet of my code, where _to is the starting point of the needed string and curr_line is the result of geany.lines(..):

  if ( #curr_line > (_to+1) ) then
    _strip_from,_strip_to=string.find(curr_line,"[ \t]*\n",_to+1)
    if _strip_from then
      print(string.format("strip from pos %d to %d",_strip_from,_strip_to))
      cmd=string.sub(curr_line,_to+1,_strip_from)
    else
      cmd=string.sub(curr_line,_to+1)
    end
    ...

Thanx
-- 
Email: Joerg Desch <jd DOT vvd AT web DOT de>



More information about the Users mailing list