1. What is wrong?

     local function handler(msg, editbox)
     local command, resst, ressst = msg:match("^(%S*)%s*(.-)$");
     if command == "add" and resst ~= "" and ressst ~= "" then
     print("command "..resst.." rest "..ressst.." ttt")
      elseif command == "remove" and resst ~= "" and ressst ~= "" then
     else
     print("Syntax: /yourcmd (add|remove) someIdentifier");
     end
     end
    

    I'm writing /command $add $resst $ressst

  2. I'm not sure what you're saying at the end, but here are some comments:

    ressst will always be nil, because your pattern only has two captures.

    The following seems to be what you want, perhaps:

     local function handler(msg, editbox)
        local command, rest = msg:match("^(%S*)%s*(.-)$");
        if command == "add" and #rest > 0 then
            print("Got request to add " .. rest)
        elseif command == "remove" and #rest > 0 then
            print("Got request to remove " .. rest)
        else
            print("Syntax: /yourcmd (add|remove) someIdentifier");
        end
     end
    
  3. I'm not sure what you're saying at the end, but here are some comments:

    ressst will always be nil, because your pattern only has two captures.

    The following seems to be what you want, perhaps:

     local function handler(msg, editbox)
      local command, rest = msg:match("^(%S*)%s*(.-)$");
      if command == "add" and #rest > 0 then
          print("Got request to add " .. rest)
      elseif command == "remove" and #rest > 0 then
          print("Got request to remove " .. rest)
      else
          print("Syntax: /yourcmd (add|remove) someIdentifier");
      end
     end
    

    No I need to 3 values ​​were. For example: /command values1 values2 values3

  4. Then your pattern is wrong. How about the following:

     local function handler(msg, editbox)
        -- Grab all non-space tokens into a table
        local tokens = {}
        for token in msg:gmatch("%S+") do
            tokens[#tokens+1] = token
        end
    
        local command = tokens[1]
        if command == "add" and tokens[2] and tokens[3] then
            print(string.format("Add: %s, %s", tokens[2], tokens[3]))
        elseif command == "remove" and tokens[2] and tokens[3] then
            print(string.format("Remove: %s, %s", tokens[2], tokens[3]))
        else
            print("Syntax: /yourcmd (add|remove) someIdentifier");
        end
     end
    
  5. Then your pattern is wrong. How about the following:

     local function handler(msg, editbox)
      -- Grab all non-space tokens into a table
      local tokens = {}
      for token in msg:gmatch("%S+") do
          tokens[#tokens+1] = token
      end
     
      local command = tokens[1]
      if command == "add" and tokens[2] and tokens[3] then
          print(string.format("Add: %s, %s", tokens[2], tokens[3]))
      elseif command == "remove" and tokens[2] and tokens[3] then
          print(string.format("Remove: %s, %s", tokens[2], tokens[3]))
      else
          print("Syntax: /yourcmd (add|remove) someIdentifier");
      end
     end
    

    And you can do easier?

  6.  function razdelitell(msg)
         local tokens = {}
         for token in msg:gmatch("%S+") do
             tokens[#tokens+1] = token
         end
     end
    
     local function handler(msg, editbox)
     local command = razdelitell(msg)
         if command == "add" and tokens[2] and tokens[3] and tokens[4] then
            SendChatMessage(string.format("Add: %s, %s, %s", tokens[2], tokens[3], tokens[4]))
         elseif command == "remove" and tokens[2] and tokens[3] then
             print(string.format("Remove: %s, %s", tokens[2], tokens[3]))
         else
             print("Syntax: /yourcmd (add|remove) someIdentifier");
         end
      end
    

    I'm trying to do and it does not work: (

  7. What you wrote makes no sense. Use what I wrote. Or att return tokens to the end of the extra function you added.

  8. What you wrote makes no sense. Use what I wrote. Or att return tokens to the end of the extra function you added.

    I'll use what you have written. But I want to learn new things. Help please ::)

  9. Add "return tokens" to the end of razdelitell and that should work too.

  10. thank you

  11. Do not do that to your posts. Just leave them.