惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
IT之家
IT之家
T
The Blog of Author Tim Ferriss
V
V2EX
博客园 - 聂微东
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
U
Unit 42
Vercel News
Vercel News
L
LangChain Blog
博客园 - 司徒正美
H
Help Net Security
Recent Announcements
Recent Announcements
Recorded Future
Recorded Future
V
Visual Studio Blog
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
Y
Y Combinator Blog
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
F
Fortinet All Blogs
B
Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园_首页
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
量子位
I
InfoQ
小众软件
小众软件
P
Proofpoint News Feed

博客园 - 秋天

sqlserver触发器 ASP.NET Core 性能对比评测(ASP.NET,Python,Java,NodeJS) URL地址中使用中文作为的参数【转】 百度地图API操作 [ASP.Net ]利用ashx搭建简易接口 使用RMS API 自定义Office(Word、Excel、PPT)加密策略 C#Excel文件加密实现,支持xlsx、docx、pptx(C#\Net\Asp.Net) - 秋天 - 博客园 使用vs2015搭建Asp.net Core 千万级规模高性能、高并发的网络架构经验分享 ASP.NET MVC学习系列(二)-WebAPI请求 浅谈HTTP中Get与Post的区别 ASP.NET MVC学习系列(一)-WebAPI初探 .net下web页生产一维条形码 微软源代码管理工具TFS2013安装与使用详细图文教程(Vs2013) Nginx搭建反向代理服务器过程详解 windows下安装nginx 我的架构设计~用层关系图说说mvc,mvvm,soa,ddd Ajax中Get请求与Post请求的区别 将String转化成Stream,将Stream转换成String
js中对String去空格
秋天 · 2019-11-26 · via 博客园 - 秋天
学习了,记录下~

str为要去除空格的字符串:
去除所有空格:   
str   =   str.replace(/\s+/g,"");       
去除两头空格:   
str   =   str.replace(/^\s+|\s+$/g,"");
去除左空格:
str=str.replace( /^\s*/, '');
去除右空格:
str=str.replace(/(\s*$)/g, "");

SCRIPT LANGUAGE="JavaScript">    
<!--    
//出处:网上搜集    
// Trim() , Ltrim() , RTrim()    
String.prototype.Trim = function()    
{    
returnthis.replace(/(^\s*)|(\s*$)/g, "");    
}    
String.prototype.LTrim = function()    
{    
returnthis.replace(/(^\s*)/g, "");    
}    
String.prototype.RTrim = function()    
{    
returnthis.replace(/(\s*$)/g, "");    
}    
//-->    
</SCRIPT>    
<input type="text" value="    前后都是空格     " id="space">    
<input type="button" value="去前后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.Trim();document.getElementById('space').select();">    
<input type="button" value="去前空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.LTrim();document.getElementById('space').select();">    
<input type="button" value="去后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.RTrim();document.getElementById('space').select();">    
<input type="button" value="还原" onclick="javascript:document.getElementById('space').value='      前后都是空格     ';">    
<a href="http://www.yaoasnsi.com" target="_blank">访问yaosansi.com</a> 

去除所有空格: 
str = str.replace(/\s+/g,"");
去除两头空格: 
str = str.replace(/^\s+|\s+$/g,"");
去除空格(TimeSheet用过)
arg0=arg0.replace(/\s+$|^\s+/g,"");

来源:http://www.cnblogs.com/fumj/p/3406420.html