title: Use single pattern to string match multiple words Lua script
body: <p>I have simple text as below:</p>
  
  <pre><code>Hello World [all 1]
  Hi World [words 2]
  World World [are 3]
  Hello Hello [different 4]
  </code></pre>
  
  <p>I want set all words in the square bracket as the variable in array using Lua.
  I try this code below:</p>
  
  <pre><code>text = 'Hello World [all 1]\nHi World [words 2]\nWorld World [are 3]\nHello Hello [different 4]'
  
  array = {string.match(text, '[%a%s]*%[([%a%s%d]*)%]')}
  
  for i = 1,#array do
  print(array[i])
  end
  </code></pre>
  
  <p>The output is  "all 1". My objective is to printout output as</p>
  
  <pre><code>all 1
  words 2
  are 3
  different 4
  </code></pre>
  
  <p>I have tried to add 3 same patterns as below:</p>
  
  <pre><code>array = {string.match(text, '[%a%s]*%[([%a%s%d]*)%].-[%a%s]*%[([%a%s%d]*)%].-[%a%s]*%[([%a%s%d]*)%].-[%a%s]*%[([%a%s%d]*)%]')}
  </code></pre>
  
  <p>It is working. But I don't think it is the best way especially when the text have load of lines like 100, etc. What is the proper way to do it? </p>
  
  <p>thanks in advance.</p>