javascript 扩充String类型的函数功能
2007-07-03 14:29
375 查看
String.prototype.trim = function(){ return this.replace(/(^[\s]*)|([\s]*$)/g, "");
String.prototype.ltrim = function(){ return this.replace(/(^[\\s]*)/g, ""); }
String.prototype.rtime = function(){ return this.replace(/([\\s]*$)/g, ""); }
String.prototype.realLength = function(){ return this.replace(/[^\\x00-\\xff]/g,"**").length; }//计算字符串的长度,一个汉字两个字符
//功能:检测是否为空或NULL值 String.prototype.isNullOrEmpty = function() { return this.trim().realLength() < 1 ? true : false; }
String.prototype.toLower = function() { return this.toLowerCase(); }
String.prototype.toUpper = function() { return this.toUpperCase(); }
String.prototype.ltrim = function(){ return this.replace(/(^[\\s]*)/g, ""); }
String.prototype.rtime = function(){ return this.replace(/([\\s]*$)/g, ""); }
String.prototype.realLength = function(){ return this.replace(/[^\\x00-\\xff]/g,"**").length; }//计算字符串的长度,一个汉字两个字符
//功能:检测是否为空或NULL值 String.prototype.isNullOrEmpty = function() { return this.trim().realLength() < 1 ? true : false; }
String.prototype.toLower = function() { return this.toLowerCase(); }
String.prototype.toUpper = function() { return this.toUpperCase(); }
相关文章推荐
- 面试题---实现一个函数clone,可以对JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制。
- JavaScript基础 空字符串:string 类型,转成bool类型是 :false Boolean()系统函数
- 实现一个函数clone,使JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制
- JavaScript string 字符串类型的扩展函数
- JavaScript中如何检测一个变量是一个String类型?请写出函数实现
- JavaScript基础 空字符串:string 类型,转成bool类型是 :false Boolean()系统函数
- 实现一个函数clone,可以对JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制。
- 实现一个函数clone,可以对JavaScript中的5种主要的数据类型(包括Number、String、Object、Array、Boolean)进行值复制。
- javascript扩充基本类型的功能
- JavaScript的扩充类型的功能
- JavaScript的String类型replace()方法介绍和使用replace()方法实现简单html模板替换功能
- 为JavaScript类型增加方法的实现代码(增加功能)
- 给你的Javascript中的String加上Trim的功能!
- JavaScript中的Number类型、String类型、Global对象、Math对象总结
- (3)JavaScript基础(基本语法:变量与数据类型、类型转换、运算符、流程控制、函数、对象、自定义对象、原型)
- JavaScript中如何使用cookie实现记住密码功能及cookie相关函数介绍
- isArray()函数(JavaScript中对象类型判断的几种方法)
- 创建健壮的isArray()函数(JavaScript中判断对象类型的种种方法)
- 在javascript里 string 和 int 类型转换
- 浅析JavaScript中两种类型的全局对象/函数