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 |
|