I'm trying to write a script for DC++ hub based on Ptokax running on lua i'm trying to assign the nick(a variable) which has punctuation in between but it gives nil values (sPattern is ! already assigned in script)
sData = "[11:03:30] !spm sTo_Nick sFromNick message to be sent"
cmd,sToNick1,sToNick2,sFromNick ,sMessage = string.match(sData, "%b<>%s["..sPattern.."](%a*)(%s+)(%w*)(%s+)(%w*)(%s+)(%.*)")
what i want to be assigned is
cmd = spm sToNick1 = sTo , sToNick2 = Nick , sFromNick = sFromNick , sMessage = message to be sent
what i'm getting is spm sTo _ Nick
as can be seen here https://repl.it/BrAg/3
can anyone please suggest the edit or help.
You need to rearrange the capture groups:
cmd,sToNick1,sToNick2,sFromNick,sMessage =
string.match(sData, "%b<>%s["..sPattern.."](%a*)%s+(%w*)"..pattern.."(%w*)%s+(%w*)%s+(.*)")
See the updated demo