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: find text between 2 string.finds?

Previous Thread :: Next Thread 
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
16 Jun 2015 10:26 PM
Let's say my string is "one two three"

I wanna somehow get the text between string.find(s,"one") and strnig.find(s,"three")

HOWEVER

Let's say my string is "three one two three"

I want it to still get the text between the first find ("one") and the second find ("three") but the second find is after the first find

My script that doesn't work due to the HOWEVER part is:

local i,j = string.find(s,"one")
local i2,j2 = string.find(s,"three")
print(string.sub(s,i,j2-1)
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
16 Jun 2015 10:29 PM
# operator then string.sub
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
16 Jun 2015 10:29 PM
string.match is really useful for this:

local val = string.match(s, "one (.-) three");
Report Abuse
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
16 Jun 2015 10:30 PM
cnt you saved my life again
i hate string manipulation
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
16 Jun 2015 10:31 PM
Well it's pretty simple in this case:

'one (.-) three'
First it'll fine a one that is followed by a space, then followed by a series of characters followed by a space, then followed by a three.
The parenthesis around .- (which gets characters non-greedily) make it so you get it returned, captured.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
16 Jun 2015 10:32 PM
@teamkilled I hate the scrubs on your autoduels.
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