local str = 'sample12_3 Word [link:a12]' result, _ = str:match("%[link:([^][]*)]") print(result)