In general, you should use multiple classes in the HTML.
<div class="shape shape-3-corners"></div>
<div class="shape shape-4-corners"></div>
Both divs are in the group of divs which represent shapes.
Only one div is in each of the group that represent shapes with a particular number of corners.
You could also look at pattern matching with attribute selectors. Unfortunately, the syntax is somewhat limited.
[class*="elem-"] would work for your particular example, but give you false positives for class="not-elem-3".
[class^="elem-"] would work for your particular example, but give you false negatives for class="another-class and elem-3".
You could also group your selectors:
.elem-1,
.elem-2 { }
… but then you would have to specify every number, and update the CSS if you added more. If you had a lot, it would get quite unwieldy.
,elem-1,elem-2{}