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: getting a part of a string

Previous Thread :: Next Thread 
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 05:02 PM
How would I turn this string:
{"AssetId":1337,"AssetVersionId":1227}

Into this:
1227

The AssetVersionId will become a bigger number over time.
Report Abuse
bluemantrolls101 is not online. bluemantrolls101
Joined: 31 Oct 2013
Total Posts: 322
02 Nov 2015 05:19 PM
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation
Report Abuse
Zaxerion is not online. Zaxerion
Joined: 09 Feb 2013
Total Posts: 2304
02 Nov 2015 05:22 PM
local string = "{"AssetId":1337,"AssetVersionId":1227}"

local function decode(str)

end

decode(string)

Theres a start, lol
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 07:33 PM
Solved:

local r1 = "{"AssetId":1337,"AssetVersionId":1227}"

local r = 38 + string.len(string.sub(r1, 39))
print(string.sub(r1, 39, tonumber(r) - 1))

This makes it so that no matter how large the number, it will always output the correct numbers.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
02 Nov 2015 07:37 PM
local s = [[{"AssetId":1337,"AssetVersionId":1227}]]
local ss = s:match("%d+}$")
ss=ss:sub(1,#ss-1)
print(ss)



Red Blossoms
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
02 Nov 2015 07:38 PM
cleaner:

local s = [[{"AssetId":1337,"AssetVersionId":1227}]]
local ss = s:gsub("}",""):match("%d+$")
print(ss)



Red Blossoms
Report Abuse
ash877 is not online. ash877
Joined: 18 Feb 2008
Total Posts: 5142
02 Nov 2015 07:56 PM
why is everyone except for ray doing this wrong XD
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 08:03 PM
Mine is just as short.
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
02 Nov 2015 08:07 PM
Why all this string matching fuss when this could be done easily with JSONEncode and JSONDecode..
Report Abuse
ThrownException is not online. ThrownException
Joined: 17 Apr 2009
Total Posts: 1945
02 Nov 2015 08:23 PM
http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONEncode

It turns a string into JSON.

What I needed was it to be in non-JSON form.

I already solved it.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
02 Nov 2015 08:25 PM
http://wiki.roblox.com/index.php?title=API:Class/HttpService/JSONDecode
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