title: A regex that converts text lists to html in PHP
body: <p>I'm trying to code a regexp to convert a block of text:</p>
  
  <pre><code>* List item
  * Another list item
  </code></pre>
  
  <p>to html:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;List item&lt;/li&gt;
      &lt;li&gt;Another list item&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I know there are snippets or classes to do this (Markdown, Textile, etc) but I think it's overkill: I really just want some basic functionality. So far I'm trying with:</p>
  
  <pre><code>$text = preg_replace("/\*+(.*)?/i","&lt;li&gt;$1&lt;/li&gt;",$text);
  </code></pre>
  
  <p>But I don't know how to wrap everything in &lt;ul&gt; tags without using a separate replace, like so:</p>
  
  <pre><code>$text = preg_replace("/(\&lt;li\&gt;(.*)\&lt;\/li\&gt;\n*)+/is","&lt;ul&gt;\n$1\n&lt;/ul&gt;\n",$text);
  </code></pre>
  
  <p>This interferes with other code, for example ordered lists. There must be a better way.</p>
  
  <p>Thanks.</p>