String.prototype.trim=function是什么意思?
来源:互联网 发布:达拉然火焰卡背淘宝 编辑:程序博客网 时间:2024/06/05 05:42
即:为字符串类型定义trim()方法
举个栗子:
String.prototype.trim = function(){
//用正则表达式将前后空格用空字符串替代。
return this.replace(/(^\s*)|(\s*$)/g,"");
}
/**
* @description : trim
* @type : String.prototype
*/
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
var usernamevalue = document.getElementById("username").value.trim();
var s = " abc ";
s = s.trim(); // s是个String,可以使用刚定义的trim方法。
alert(s);
阅读全文
0 0
- String.prototype.trim=function是什么意思?
- JS中 String.prototype.Trim = function()
- String.prototype.trim=function是做什么用的?
- String.prototype.trim= function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); };
- String.prototype.trim
- js String.prototype.trim()
- c++ trim function string
- String.prototype.trim是做什么用的?
- Perl trim function to strip whitespace from a string
- jquery 中$.trim()是什么意思?
- toString().trim()是什么意思
- !function(){}() ” 是什么意思
- String.trim
- String.trim()
- String.Trim
- Function Prototype
- function trim() 问题
- ORACLE/PLSQL: TRIM FUNCTION
- python科学计算——numpy(1)
- 公司给你一堆以前别人开发的老系统,你怎么快速梳理清楚
- HSSFWorkbook使用java代码导出excel
- NoSQL概念
- Apache Spark 2.2.0 中文文档迭代翻译活动,期待您的参与 | ApacheCN
- String.prototype.trim=function是什么意思?
- Mysql分析-profile详解
- Cocos2d-3.X--分析Ref类
- 解决git The following untracked working tree files would be overwritten by merge
- 一起lintcode ------- 二分查找看这篇就够了
- Angular实现tab切换
- spring文章记录
- HFOI2017.7.14校内赛(普及组)题解
- B