title: Replacing Heading (<h1>, <h2> ...) Tags with <p> Tags and Classes
body: <p>I wish to replace  tags from a WYSIWYG editor to .</p>
  
  <p>At the moment I am using the following code to achieve this.</p>
  
  <pre><code>$content = preg_replace('/&lt;h1(.*?)&lt;\/h1&gt;/si', '&lt;p class="heading-1"$1&lt;/p&gt;', $content);
  $content = preg_replace('/&lt;h2(.*?)&lt;\/h2&gt;/si', '&lt;p class="heading-2"$1&lt;/p&gt;', $content);
  $content = preg_replace('/&lt;h3(.*?)&lt;\/h3&gt;/si', '&lt;p class="heading-3"$1&lt;/p&gt;', $content);
  $content = preg_replace('/&lt;h4(.*?)&lt;\/h4&gt;/si', '&lt;p class="heading-4"$1&lt;/p&gt;', $content);
  $content = preg_replace('/&lt;h5(.*?)&lt;\/h5&gt;/si', '&lt;p class="heading-5"$1&lt;/p&gt;', $content);
  $content = preg_replace('/&lt;h6(.*?)&lt;\/h6&gt;/si', '&lt;p class="heading-6"$1&lt;/p&gt;', $content);
  </code></pre>
  
  <p>As you can see this code is quite messy, it would be great if I could condense this into a single regular expression but I simply lack the ability to do so.</p>
  
  <p>I had considered this line of code as an alternative.</p>
  
  <pre><code>$content = preg_replace('/&lt;h(.*?)&lt;\/h(.*?)&gt;/si', '&lt;p class="heading-$2"$1&lt;/p&gt;', $content);
  </code></pre>
  
  <p>I'm not sure about using the above, clients have a tendency to copy content from other sites, paste it straight into their new WYSIWYG and i've seen anything from hr tags to heading tags popping in there. </p>
  
  <p>What I require is simply the above single line, except the tag itself can only be 2 specific characters (So ensure the tag starts with a H and is followed by [1-6]).</p>
  
  <p>I also require that the class it adds to the p tag is specific to the number use, eg: heading-1, heading-2.</p>
  
  <p>Any help would be greatly appreciated, thank you for your time.</p>