Hello, I want to get the name and description data from this string name=Lamp,description=Just a lamp so I want to set get the Lamp and Just a lamp and set those to respected variables how can I do this I’ve been trying all night to understand the character codes etc.
I’m so confused. What is your question?
You should be able to do:
local name, desc = str:match("name=(.+),description=(.+)")
Maybe I dont understand string captures but I tried this
local match, match2 = string.match("name=Lamp,description=Just a lamp", "(%u%l+)%l*%p*(%u%l+)")
print(match, match2)
and the (%u%l+) is able to get Lamp but I’m not sure how to get the second part this %l*%p*(%u%l+) just ruins it.
Thats actually an interesting idea, and you almost have it down, but if I was going to use a system like that I would probably use sets to detect it instead like this
local match, match2 = string.match("name=Lamp,description=Just a lamp", "(%u%l+)[%l%p]+(%u[%l%s]+)")
print(match, match2)
This will tell lua to choose any combination of whatevers in the square brackets [], allowing you to have complex combinations of letters and spaces and punctuation and stuff