[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: string.sub failing?
- From: Shmuel Zeigerman <shmuz@...>
- Date: Tue, 01 Nov 2005 17:52:42 +0200
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.
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")
if i ~= nil then
Name = string.sub(Name, 1, string.len(Name) - 5)
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!