lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Your code works for me with Lua 5.1 alpha.
It may be that your files' extensions that you try to strip out
are not in lower case.

-- Shmuel


Framework Studios: Hugo wrote:
I'm trying to strip an extention from a filename. It used to work with LUA
5.0, however I just switched to 5.1 and I get a different result.

Here's the code:

 -- strip .prst
 local i = string.match(Name, ".prst")
 msg(Name)
 if i ~= nil then
  Name = string.sub(Name, 1, string.len(Name) - 5)
  msg(Name)
 end

The 'msg' function simply shows a message-box with the given string. Of
course with LUA 5.0 'string.match' used to be 'string.find'. Also with 5.0 I
used the result of 'string.find' in stead of 'string.len'.

On LUA 5.0 I got two messages, one with the Name inclusing '.prst' and one
without the '.prst'. However with LUA 5.1 the second message is empty!