I'm stuck with something
So, I am writing something that requires a certain character of a string. So, like, is there a way to return... say, the third letter of the string "love"? And it would return "v"?
Any idea?
Help with strings.
Started by ebernerd, Feb 01 2015 03:09 AM
2 replies to this topic
#1
Posted 01 February 2015 - 03:09 AM
#2
Posted 01 February 2015 - 03:09 AM
print( string.sub( "love", 3, 3 ) )
#3
Posted 01 February 2015 - 03:33 AM
Just to elaborate further, string.sub() takes (string,starting point,[ending point]), if no ending point is given it will just go to the end of the string.
You can also use negatives to work at the end of the string, such as
http://lua-users.org...LibraryTutorial
You can also use negatives to work at the end of the string, such as
string.sub("love",-2)
would return "ve"http://lua-users.org...LibraryTutorial
Edited by Quintuple Agent, 01 February 2015 - 03:34 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











