[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: string.sub failing?
- From: "Framework Studios: Hugo" <hugo@...>
- Date: Tue, 1 Nov 2005 16:05:50 +0100
Hi,
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!
Any ideas to what I'm doing wrong?
Thanks!
Hugo