Select elements whose class ends with particular string
<p>This has probably been answered before but I don't know how to phrase it properly.</p>

<p>For elements:</p>

<pre><code>&lt;div id='div1' class="class1 1foobar"&gt;&lt;/div&gt;
&lt;div id='div2' class="class1 class2 2foobar"&gt;&lt;/div&gt;
</code></pre>

<p>How do I get the NAME of the class ending with 'foobar'? So for 'div1' I want to get a string '1foobar' and for 'div2' I want to get string '2foobar'.</p>