title: Detecting beginning of line and end of line in preg_replace
body: <pre><code>$data = $_POST['data'];
  
  echo '&lt;form method="post"&gt;&lt;textarea name="data"&gt;&lt;/textarea&gt;&lt;input type="submit"&gt;';
  
  echo preg_replace( "#/*[?+]/n#", "[h1]$1[/h1]",$str );
  </code></pre>
  
  <p>Is it possible with <code>preg_replace</code> to detect the beginning of a line and apply a certain html code to the entire line based on a few characters at the beginning of it?</p>
  
  <p>Here, based on the * if the data were:</p>
  
  <pre><code>*This is row one
  //output &lt;h1&gt;This is row one&lt;/h1&gt;
  
  **This is row two
  //output &lt;h2&gt;This is row two&lt;/h2&gt;
  
  ***This is row three
  //output &lt;h3&gt;This is row three&lt;/h3&gt;
  
  ***This is row * three
  //output &lt;h3&gt;This is row * three&lt;/h3&gt;
  
  This is row * three
  //output This is row * three
  </code></pre>
  
  <p>I'm having troble detecting the begining of the line and end of the line and wrapping tags around the text in the line.</p>
  
  <p>I don't need any <code>*</code> in between the line matched. My failed effors are included. Can you help?</p>