Saving text and inserting it after a specified variable
<p>there's a site with lots of comments. </p>

<pre><code>code1
&lt;p&gt;hello ernie&lt;/p&gt;
&lt;p&gt;this is mark&lt;/p&gt;
&lt;p&gt;hello ben&lt;/p&gt;
&lt;p&gt;this is ernie&lt;/p&gt;
&lt;p&gt;hello mark&lt;/p&gt;
&lt;p&gt;this is ben&lt;/p&gt;
</code></pre>

<p>Now I want to collect all comments containing 'hello' and insert the phrases with hello after all comments.</p>

<pre><code>$("p:contains('hello')").insertAfter($("#comments"));
</code></pre>

<p>'hello' is taken from the comments and inserted after the comments.</p>

<pre><code>code2
&lt;p&gt;this is mark&lt;/p&gt;
&lt;p&gt;this is ernie&lt;/p&gt;
&lt;p&gt;this is ben&lt;/p&gt;
</code></pre>

<pre><code>code3
&lt;p&gt;hello ernie&lt;/p&gt;
&lt;p&gt;hello ben&lt;/p&gt;
&lt;p&gt;hello mark&lt;/p&gt;
</code></pre>

<p>Is there a way to keep the comments as they were (code1) and still insert all comments containing 'hello' after the comments.  Like</p>

<p>How it should look like.</p>

<pre><code>
&lt;p&gt;hello ernie&lt;/p&gt;
&lt;p&gt;this is mark&lt;/p&gt;
&lt;p&gt;hello ben&lt;/p&gt;
&lt;p&gt;this is ernie&lt;/p&gt;
&lt;p&gt;hello mark&lt;/p&gt;
&lt;p&gt;this is ben&lt;/p&gt;
</code></pre>

<pre><code>
&lt;p&gt;hello ernie&lt;/p&gt;
&lt;p&gt;hello ben&lt;/p&gt;
&lt;p&gt;hello mark&lt;/p&gt;
</code></pre>

<p>Any hint or help is much appreciated.</p>
