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
 

string.find() troubles

Previous Thread :: Next Thread 
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
03 Apr 2015 03:06 PM
Honestly, I have no idea what's going wrong here:

local save_id = "save[Test]"
local _, _, server_id = string.find(save_id, "save[(%.+)]")
print(server_id)

Prints "nil", even though it should be printing "Test".
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 03:10 PM
wot is dis + & % junk
I dun comprende, I remembr when strings were strings, and nawt sign & character jibberish

;-;-;-;-;-;-;-;
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
03 Apr 2015 03:11 PM
http://wiki.roblox.com/index.php?title=String_patterns#Character_Classes
Report Abuse
Froast is not online. Froast
Joined: 12 Mar 2009
Total Posts: 3134
03 Apr 2015 03:11 PM
The reason is because brackets are actually a part of patterns, in order to interpret them literally you have to append them with "%".

local save_id = "save[Test]"
local _, _, server_id = string.find(save_id, "save%[(.+)%]")
print(server_id)

Also, for this I feel like string.match is more appropriate.

local save_id = 'save[Test]'
local server_id = save_id:match'save%[(.*)%]'
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
03 Apr 2015 03:11 PM
http://wiki.roblox.com/index.php?title=String_patterns#string.match

Here ye go


~Commands? Commands. www.roblox.com/Admin-item?id=232183441
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 03:13 PM
danke MM bb, I now kn0w h0w 2 find whitespace st00f

xdd
Report Abuse
MM233 is not online. MM233
Joined: 19 Jun 2008
Total Posts: 925
03 Apr 2015 03:15 PM
@Froast: Yeah, I was wondering about that. Thanks.
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