<script>
var str = "  < test test > te st ";
var re = / *(<+.*>+) */gi;
str = str.replace(re,"$1");
alert(str);
</script>