title: How do I make match stop on first occurance?
body: <p>I need to digest some bbcode with a Ruby regular expression. </p>
  
  <p>I have to delimit the elements with the <code>match</code> command and use a regexp <code>/pattern/m</code> to get rid of newlines.</p>
  
  <p>For example, my bbcode in a string is:</p>
  
  <pre><code>s="[b]Title[/b] \n Article text \n [b]references[/b]"
  </code></pre>
  
  <p>Then I use <code>match</code> to delimit the parts of the text, especially the Title and the References parts which are enclosed between <code>[b]</code> and <code>[/b]</code>:</p>
  
  <pre><code>t=s.match(/\[b\](.*)\[\/b\]/m)
  </code></pre>
  
  <p>I use <code>(..)</code> syntax to catch a string in the regexp and I use <code>\</code> to escape the special <code>[</code> and <code>]</code> characters. <code>/m</code> is to get rid of newlines in the string.</p>
  
  <p>Then <code>t[1]</code> contains:</p>
  
  <pre><code>"Title[/b] \n Artucle text \n [b]references"
  </code></pre>
  
  <p>instead of <code>"Title"</code>. because the match doesn't stop at the first occurance of <code>[/b]</code>. And <code>t[2]</code> is nil instead of "References" for the same reason.</p>
  
  <p>How can I delimit the text parts enclosed between the usual bbcode tags?</p>