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 help

Previous Thread :: Next Thread 
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 06:20 PM
I have a string, for example:
a = "asd/g4/awe5/s"

The amount of slashes vary. I want to run a script that automatically sees how many slashes exist, and adds into a table whats in between each slash, so that the table would look like this: tab={"asd","g4","awe5","s"}

Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jan 2012 06:23 PM
Tab = {
Slashes = 0
table.insert(Tab, a:match("(.-)/")
for sor in a:gmatch("/(%w+)") do
Slashes = Slashes + 1
table.insert(sor)
end

print(unpack(Tab), Slashes)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jan 2012 06:24 PM
*a:gmatch("/(%w-)"
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jan 2012 06:27 PM
*Tab = {}

Dangitall
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jan 2012 06:27 PM
*table.insert(Tab, sor)

If I find one more mistake, I'm gonna BLOW UP
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 06:29 PM
u forgot paranthesis in the end of the string thing
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 06:36 PM
issnot really working..
Tab = {}
Slashes = 0
a = "asd/g4/awe5/s"
--table.insert(Tab, a:gmatch("/(%w-)"))
for sor in a:gmatch("/(%w-)") do
Slashes = Slashes + 1
table.insert(Tab, sor)
end

print(unpack(Tab), Slashes)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jan 2012 07:16 PM
Tab = {}
Slashes = 0
a = "asd/g4/awe5/s"
table.insert(Tab, a:match("(%w-)/"))
for sor in a:gmatch("/(%a+)") do
Slashes = Slashes + 1
table.insert(Tab, sor)
end
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:18 PM
Thanks.
Almost though, it doesn't count the numbers :I
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
05 Jan 2012 07:23 PM
table.foreach(Tab, print)


<---dun lik string patterns
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
05 Jan 2012 07:23 PM
table.foreach(Tab, print)


<---dun lik string patterns
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
05 Jan 2012 07:23 PM
double post :)
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:24 PM
yea, but that doesn't help me :/
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:25 PM
Tab = {}
Slashes = 0
a = "HatHelper/Snow Zombie"
table.insert(Tab, a:match("(%w-)/"))
for sor in a:gmatch("/(%w+)") do
table.insert(Tab, sor)
end
print(table.concat(Tab, ' '))


This works to a certain extent.
It doesn't recognize the space character. I tried replacing with other non-letter characters, but "%w" only works for alphabet and numbers.

Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
05 Jan 2012 07:26 PM
you wanted it to count them out?
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:27 PM
No?
Read the thread. Or just the first post.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
05 Jan 2012 07:43 PM
AMG!


txt = ""
t = {}
for M in txt:match("(%w+)/?") do
table.insert(t, M)
end

table.foreach(t, print)
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:45 PM
" attempt to call a string value"
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
05 Jan 2012 07:49 PM
Onoes.
table.foreach doesn't work anymore.
I also forgot the g in gmatch. >_>


txt = "asdf/321d/123rwdcff/12rwsed/gdsfhdsa/3rtge/r"
t = {}
for M in txt:gmatch("(%w+)/?") do
table.insert(t, M)
end

for _, v in pairs(t) do
print(v)
end
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:50 PM
problem :0


txt = "HatHelper/Snow Zombie"
t = {}
for M in txt:gmatch("(%w+)/?") do
table.insert(t, M)
end

for _, v in pairs(t) do
print(v)
end


Prints Snow Zombie as two words.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
05 Jan 2012 07:54 PM
After a few experiments, I will post the approximate source of the string.gmatch function. ;P
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
05 Jan 2012 07:54 PM
txt = "HatHelper/Snow Zombie"
t = {}
for M in txt:gmatch("([%w+%s*]+)/?") do
table.insert(t, M)
end

for _, v in pairs(t) do
print(v)
end
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:54 PM
I'm tempted to just use loops to figure it out
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
05 Jan 2012 07:55 PM
String patterns. Are fun. Don't give up!
I'm currently working on a differentiation function to differentiate my equations for me.
For Calculus.
:o :o
:o :o
Report Abuse
HatHelper is not online. HatHelper
Top 25 Poster
Joined: 02 Mar 2009
Total Posts: 46305
05 Jan 2012 07:56 PM
i aint to calculus so idk

i dont understand string patterns at all yet.
ill teach myself tomorrow at school.
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