This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lukasloko's profile picture

split string using words

Started by lukasloko, 07 February 2016 - 12:26 AM
lukasloko #1
Posted 07 February 2016 - 01:26 AM
I already made some question about that kinda of stuff some time ago, but only now i'm having problems and question about that again.

I'm making routers and programs that communicate with others programs. The programs need to split the messages that they receive from the others into blocks (like password$nickname$balance$status) and then process it. And I have not much more characters to use as split pattern without overlapping.

My question is:

Can you split strings using words like:
Spoilermsg = "I like %word% my computer"
for token in msg:gmatch("[^%word%]+") do
print(token)
end
Output:
SpoilerI like
my computer

maybe it has a easy awsner but i'm not able to figure out it.
The_Cat #2
Posted 07 February 2016 - 01:40 AM
Why not just use a table to send the data? Then you could simply do something like tableName.password, tableName.username… etc
lukasloko #3
Posted 07 February 2016 - 01:42 AM
Hmmm, that could work the way that i'm looking for. I will try thank you for the hint