JavaScript拡張Stringの方法
420 ワード
<script>
/**
* String trim
*/
String.prototype.trim = function() {
// js java , js //
// return this.replace(/(^\s+)|(\s+$)/, ""); //
return this.replace(/(^\s+)|(\s+$)/g, "");
}
var str = " aaa ";
alert("[" + str.trim() +"]");
</script>