Jump to content




String Manipulation Help

help

  • You cannot reply to this topic
3 replies to this topic

#1 DarkNinja2462

  • Members
  • 107 posts
  • LocationThe 4th Dimension

Posted 08 April 2012 - 01:49 AM

Is it possible to take a piece of a string, and get the length of a string?
I know they have that for the TI-84 plus.
Can you give me the syntax, or at least where to find it?
RECAP: Can I take a piece of a string and find the length of it?

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 08 April 2012 - 01:53 AM

You can use string.sub to get substrings, and string.len or the lenght operator (#).
local s = string.sub(your_string, pos1, pos2)
print("The substring is: ", s)
print("It's lenght is: ", #s)
Check out this link for more lua string functions: StringLibraryTutorial

#3 EatenAlive3

  • New Members
  • 53 posts

Posted 08 April 2012 - 02:02 AM

Length usage:
string = "cabbage"
return string:len()
> returns 7


#4 Hawk777

  • Members
  • 162 posts

Posted 08 April 2012 - 07:34 AM

If you take substrings, be aware of this bug.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users