<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
var static = 'a1', reg = new RegExp('\s*'+static+'\s*','')
var cl2 = $.trim($("div."+static).attr('class').replace(reg,''));
alert(cl2);
});
</script>
</head>
<body>
<div class="a1 b2">class="a1 b2"</div>
</body>
</html>