title: Regex : expression at beginning of line OR NOT
body: <p>I'm trying to work with some regex in PHP but there is something i don't understand.
  Here is my text:</p>
  
  <pre><code># fhzmvbzmvbzmb#@!
  # blabla
  # test
  sbsfzzbg
  </code></pre>
  
  <p>And let's say i want to emphasise it as in markdown. Why does the following function apply to my second line only ? I would expect it to apply to the third line as well.</p>
  
  <pre><code>preg_replace("/\n(.*)\n/", "&lt;h1&gt;$1&lt;/h1&gt;", $input_lines);
  </code></pre>
  
  <p>Also, i want to catch the first line. Is there a way to write the expression i am trying to catch could either be at the beginning of the string or not ? I've thought about the next function but it doesn't seem to work:</p>
  
  <pre><code>preg_replace("/(^|\n)(.*)\n/", "&lt;h1&gt;$1&lt;/h1&gt;", $input_lines);
  </code></pre>
  
  <p>Thank you very much.
  Pierrick</p>