首页 > 编程语言 > 详细

JavaScript—字符串(String)用法

时间:2019-10-16 20:00:01      阅读:53      评论:0      收藏:0      [点我收藏+]

字符串(String)去除空格

str = "  hello  python  "
// 去除左空格:
str=str.replace( /^\s*/, ‘‘);

// 去除右空格:
str=str.replace(/(\s*$)/g, "");

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

// 去除所有空格:   
str = str.replace(/\s+/g,"");  

  https://www.cnblogs.com/jun-qi/p/11057421.html

JavaScript—字符串(String)用法

原文:https://www.cnblogs.com/liuhaidon/p/11687240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!