drarem Posted December 14, 2015 Share Posted December 14, 2015 I thought this would be an easy task.. how do I get a substring, like the 5th byte of a string? Such as this: "ABCDEFG" > return 'E' Thanks Quote Link to comment Share on other sites More sharing options...
thehankinator Posted December 14, 2015 Share Posted December 14, 2015 Have you tried string.sub()? http://www.lua.org/pil/20.html Quote Link to comment Share on other sites More sharing options...
drarem Posted December 14, 2015 Author Share Posted December 14, 2015 Here's what happens, where fileinput starts out as a table.. local astr = fileinput.tostring() System:Print(astr) -- looks ok System:Print("as:cahr = :"..string:sub(astr,1,1)) -- error, expecting string got table Quote Link to comment Share on other sites More sharing options...
thehankinator Posted December 14, 2015 Share Posted December 14, 2015 Here's what happens, where fileinput starts out as a table.. local astr = fileinput.tostring() System:Print(astr) -- looks ok System:Print("as:cahr = :"..string:sub(astr,1,1)) -- error, expecting string got table change string:sub() to string.sub() you have stringcolonsub(), you need stringperiodsub() Quote Link to comment Share on other sites More sharing options...
drarem Posted December 14, 2015 Author Share Posted December 14, 2015 Wow, thanks.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.