title: Regex question mark
body: <p>To match a string with pattern like:</p>
  
  <pre><code>-TEXT-someMore-String
  </code></pre>
  
  <p>To get <code>-TEXT-</code>, I came to know that this works:</p>
  
  <pre><code>/-(.+?)-/ // -TEXT-
  </code></pre>
  
  <p>As of what I know, <code>?</code> makes preceding token as optional as in:</p>
  
  <p><code>colou?r</code> matches both <code>colour</code> and <code>color</code></p>
  
  <p>I initially put in regex to get <code>-TEXT-</code> part like this:</p>
  
  <pre><code>/-(.+)-/
  </code></pre>
  
  <p>But it gave <code>-TEXT-someMore-</code>. </p>
  
  <p>How does adding <code>?</code> stops regex to get the <code>-TEXT-</code> part correctly? Since it used to make preceding token optional not stopping at certain point like in above example ?</p>