<head>
<script type="text/javascript">
String.prototype.trim = function() {
var reExtraSpace = /^\s*(.*?)\s*$/;
return this.replace(reExtraSpace,"$1");
}
var test = " this is a test ";
alert("hello");
alert("["+test+"]");
alert("["+test.trim()+"]");
</script>
</head>
<body>
</body>
$1:反向引用,对于分组(.*?)