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
 

String manipulation

Previous Thread :: Next Thread 
iIikeyou is not online. iIikeyou
Joined: 07 Mar 2012
Total Posts: 1659
11 Apr 2014 05:32 PM
Say I'm making an admin script, and I isolate three parts of a chatted string like this

local message=':teleport player1 player2'

local Cmd,Name1,Name2Pos=message:match'(%S+) (%w+)()'
local Name2=message:sub(Name2Pos):match'%S+$'

Now, say I want it to be possible for the first list (Name1 in the example) to have multiple names seperated by commas
I would do this

local message=':teleport player1,player2 player3'

local Cmd,Name1,Name2Pos=message:match'(%S+) (%w+[%w,]*)()'

and the second capture would return the list of names

Now... I want it to be possible for a space to be put after each comma in the first list

How would I do this?

local message=':teleport player1, player2,player3 player4'

local Cmd,Name1,Name2Pos=message:match'(%S+) (%w+{, ?%w+}*)()'

Obviously this won't work, as curly brackets don't do anything in string manipulation, but how would I search for those characters in order like that?

It needs to be in order so I can tell the space is always after a comma, otherwise it's the second name


Thanks for the help in advance, and sorry if I explained poorly.
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