lua-users home
lua-l archive

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


2012/6/21  <meino.cramer@gmx.de>:

>
> I want to access/retrieve the n-th character.
>
…
>
> I scanned through the String Tutorial, the String Library Tutotrial
> and the online version of Programming Lua and found nothing what
> seems appropiate to me...but I am sure that's due to me.... :)
>

There's some good (though advanced) stuff on the Lua Wiki:

http://lua-users.org/wiki/StringIndexing

E.g. you're shown how to get this:

-- demo
a='abcdef'
return a[4]       --> d
return a(3,5)     --> cde
return a{1,-4,5}  --> ace

So there you have it: one-byte substrings with square brackets,
to-from substrings with round, selected bytes with curly.