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 » Scripting Helpers
Home Search
 

Re: "string.find" Output Question

Previous Thread :: Next Thread 
CyberHusky88 is not online. CyberHusky88
Joined: 27 Dec 2008
Total Posts: 396
22 Oct 2014 07:42 AM
I'm trying to call the output of string.find, but since it outputs two different numbers (The beginning of the string and the end of the string) I can't figure out how to call the separate numbers.

I am using the output in string.sub
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
22 Oct 2014 07:45 AM
....?

I don't understand what you mean "call the output of"

Unless you mean:

local S = "Hello"
local Start,End = S:find("ello");
print(S:sub(Start,End));
Report Abuse
CyberHusky88 is not online. CyberHusky88
Joined: 27 Dec 2008
Total Posts: 396
22 Oct 2014 07:50 AM
stringPositions = string.find(string, targetWord)
msg = string.sub(string, 1, *Start of found word* - 1)
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
22 Oct 2014 07:52 AM
I just told you how.....

Use two variables.
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
22 Oct 2014 07:53 AM
string = "this is a string"

print(string.find(string,"string"))
outputs
11 16

basically, you can use sub on the string.find function. this DOES not perform manipulation on the output, but manipulates wich part of string.find to take.

to get the first number, you could use this:
print(string.sub(string.find(string,"this"),1))
outputs 11


to get the second number, you could use this:
print(string.sub(string.find(string,"string")+5,1))
outputs 16.

Note the +5. the 5 is the length of the string to search for - 1
("string" is 6 long, -1 and you get 5)

Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
22 Oct 2014 07:56 AM
oops

to get the first number, you could use this:
print(string.sub(string.find(string,"this"),1))
outputs 11

it searches for this. change to "string" and you'd see the result i talked about.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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