generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What is the string function for...

Previous Thread :: Next Thread 
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
21 May 2016 02:04 PM
returning the index given one of the characters?

Example:

somestring = "abcdefgh"

somestring["b"] == 2

is it string.sub ?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
21 May 2016 02:07 PM
print(string.find("abcdefgh", "b"))

> 2 2

it returns the position of the FIRST found string within the whole string

Formerly ToxicDominator - add 17,509 posts
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
21 May 2016 02:08 PM
string.find


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
21 May 2016 02:08 PM
forgot it returned a number. Thanks
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
21 May 2016 02:12 PM
use this so it doesn't return 2 2
print(tostring(string.find("abcdefghb", "b")):sub(1))

Formerly ToxicDominator - add 17,509 posts
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
21 May 2016 02:14 PM
"use this so it doesn't return 2 2"
":sub(1))"
That doesn't help. Firstly, it returns two numbers, not one string.

local Start, End = string.find(...)

Secondly, sub(1) would return all of the letters anyways since using it with one argument returns from that argument until the end of the string.


Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
21 May 2016 02:18 PM
I'm talking about using it for purposes that having a variable hold 2 numbers wouldn't work. If you want a number, you would just use:

tonumber(tostring(string.find("abcdefghb", "b")):sub(1))

I'm not really sure what you're talking about, but that returns 2 as a number

Formerly ToxicDominator - add 17,509 posts
Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
21 May 2016 02:19 PM
i just made something do you like it


function returnStringPlaces(strin, findwhat)
local indexes={}
local total=0
repeat wait()
if strin:find(findwhat)~=nil then
indexes[#indexes+1]=strin:find(findwhat)+total
total=total+strin:find(findwhat)
strin=strin:sub(strin:find(findwhat)+1)
else break end
until strin:find(findwhat)==nil
return indexes
end
print(unpack(returnStringPlaces('bobbyhadacowbbfdb', 'b')))
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
21 May 2016 02:22 PM
It returns 2, 2, not "2 2".

It returns a tuple, two numbers.

Tuples don't work that way.


Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
21 May 2016 02:24 PM
ok jarod do a,b
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
21 May 2016 02:28 PM
and that's exactly why I used tostring() so I can manipulate it with string.sub() as if it were a string. then I could retransform it to a number

I have a feeling you still haven't tested this;

print(tonumber(tostring(string.find("abcdefghb", "b")):sub(1)) + 5)
>> 7

Formerly ToxicDominator - add 17,509 posts
Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
21 May 2016 02:31 PM
skello why would you do this
Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
21 May 2016 02:32 PM
lol all you have to do is

a=string.find("abcdefghb", "b") print(a)


jesus

holy crap

way to overcomplicate it dude
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
21 May 2016 02:36 PM
okay skids. This thread has already closed since the solution has already been mentioned. Go away.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
21 May 2016 02:37 PM
Okay then, Skello.
Your substringing still returns the whole string.
With only one argument, it returns from that argument to the end of the string.

try this:
print(tostring(string.sub("lol", "o")))


My point is, that is totally unnecessary, you need to learn how tuples work Skello.


Report Abuse
12103net is not online. 12103net
Joined: 08 Jul 2013
Total Posts: 350
21 May 2016 02:58 PM
"okay skids. This thread has already closed since the solution has already been mentioned. Go away."

ok sir mind your manners you're the one who was begging for something _really_ simple and then you decide to be rude about it when you've got what you want? lol, you're the skid buddy because obviously you're too stupid to know string manipulation
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image