title: regular expression
body: <p>I'm working for some hours on a regular expression.
  As example, original sentence is:</p>
  <pre><code>location in [chambre, cuisine, salle-de-bain, jardin]
  </code></pre>
  <p>In only one step, I want to verify that the shape is word in [word, word, word...] and I would like to catch each word. (I want to do it in only one step for performance, because this code already works with three steps, but it's too long)</p>
  <p>My current regular expression is:</p>
  <pre><code>/([a-zA-Z]+)\s+in\s+\[\s*([a-zA-Z-]+)\s*(?:,\s*([a-zA-Z-]+)\s*)*\s*\]/
  </code></pre>
  <p>I catch location, chambre and jardin. I don't catch cuisine and salle-de-bain</p>
  <pre class="lang-php prettyprint-override"><code>$condition = 'location in [chambre, cuisine, salle-de-bain, jardin]'
  $analyse = preg_match('/([a-zA-Z]+)\s+in\s+\[\s*([a-zA-Z-]+)\s*(?:,\s*([a-zA-Z-]+)\s*)*\s*\]/',$condition, $matches);
  var_dump($matches);
  </code></pre>
  <pre class="lang-json prettyprint-override"><code>array:4 [▼
    0 =&gt; &quot;location in [chambre, cuisine, salle-de-bain, jardin]&quot;
    1 =&gt; &quot;location&quot;
    2 =&gt; &quot;chambre&quot;
    3 =&gt; &quot;jardin&quot;
  ]
  </code></pre>
  <p>I don't find what is wrong in my regular expression to catch the 2 missing words. I only get the first one and the last one in array...</p>