lua-users home
lua-l archive

string.sub failing?

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


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

AltStyle によって変換されたページ (->オリジナル) /