syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

Question:
In Lua how to slice string2 from string1?
Tags: lua string slice

A common task when I work with interpreted languages is to copy string2 out of string1.

In the demo below I just slice-out the characters from position 2 to 10:
-- ~/ks/b/lua/slice_string.lua

-- Slice substring from string:
str1     = 'hello world'
myslice  = string.sub(str1,2,10)
print(myslice)


syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me