Hola,

I have a problem where I have a number of random set of elements that have a fixed rule for class name. I want to move them to a container element according to this class name.

So for example the site generates
Code:

Code:
<p class="dog-1"></p>
<p class="dog-2"></p>
<p class="cat-1"></p>
<p class="dog-3"></p>
My output would be ideally
Code:

Code:
<div class="dog">
   <p class="dog-1"></p>
   <p class="dog-2"></p>
   <p class="dog-3"></p>
</div>

<div class="cat">
   <p class="cat-1"></p>
</div>
When searching for a solution, all I could find was simple ordering of elements according to class...
Thanks