fork download
  1. local s = "[5. Trade - City] [SomeCharacterName]: Testing Chat"
  2. local result, _ = s:gsub("(%[%d+%. )Trade.-%]", "%1TR]")
  3. print( result )
  4.  
  5. local text = "[5. Trade (Services) - City] [SomeCharacterName]: Testing Chat"
  6. local res, _ = text:gsub("(%[%d+%. )Trade %([^()]*%).-%]", "%1TRS]")
  7. print( res )
Success #stdin #stdout 0s 5548KB
stdin
Standard input is empty
stdout
[5. TR] [SomeCharacterName]: Testing Chat
[5. TRS] [SomeCharacterName]: Testing Chat