Code:
local pattern = "^" .. (L[db.trigger]:gsub("(%W)", "%%%1")) .. "%s*(%d*)%s*(.-)%s*$"
Changing the match-all capture to match the least number of characters ("
.-" instead of "
.*") and adding "
%s*" at the end should make it unnecessary to call
:trim().