lua-users home
lua-l archive

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

On Tuesday 11 October 2005 21:29, Walter Cruz wrote:
> If i have a string like "Lua" :) in lua, how can I acess the "u"?

local substring = string.sub("Lua", 2, 2)

It's also possible to abuse string.byte() to do this, but that's only really 
useful in certain circumstances.

Speed tip:

local string_sub = string.sub
...lots of program here...
local substring = string_sub("Lua", 2, 2) *substantially* faster than using string.sub directly.

Check out the string page in the manual:

+- David Given --McQ-+ 
|    | "Never attribute to malice what can be adequately
| ( | explained by stupidity." --- Nick Diamos
+- --+ 

Attachment: pgpsEbrPoO0US.pgp
Description: PGP signature