dimanche 20 novembre 2016

Lua digit pattern matching not capturing

I'm attempting to match Sword and 2 in the following string.

You receive loot [Sword]x2.

This is where I've made it so far. Sword matches fine and is saved in the item variable. qty, however, always returns 'No qty' regardless of the input string.

local item, qty = msg:match('%[(.+)%]x?(%d?)') or 'No item', 'No qty'

Aucun commentaire:

Enregistrer un commentaire