当前位置:网站首页>Small example of regular expression--remove spaces in the middle and on both sides of the string
Small example of regular expression--remove spaces in the middle and on both sides of the string
2022-08-05 06:13:00 【CrazyQiQi】
Remove all spaces from a string using a regular expression
var str = " gs gdjkf gs gfsd ";str = str.trim(); //trim()Only spaces on both sides of the string can be removedvar getNewStr = function(str) { //Remove blanks in the string through regular expressionsvar reg = /^\s+|\s+|\s+$/g; //matches all whitespace at the beginning, end and in betweenstr = str.replace(reg, '')span>; //Replace all matching spaces with ''return str;}getNewStr(str); //What you get at this time is a string without spaces//gsgdjkfgsgfsd
边栏推荐
猜你喜欢
随机推荐
通过单总线调用ds18b20的问题
Getting Started Documentation 12 webserve + Hot Updates
Hugo搭建个人博客
Getting Started 04 When a task depends on another task, it needs to be executed in sequence
spark源码-任务提交流程之-7-流程梳理总结
OpenCV3.0 is compatible with VS2010 and VS2013
Getting Started Doc 06 Adding files to a stream
spark source code - task submission process - 5-CoarseGrainedExecutorBackend
Contextual non-local alignment of full-scale representations
spark源码-RPC通信机制
D39_向量
Getting Started 03 Distinguish between development and production environments ("hot update" is performed only in the production environment)
海外服务器的优势
【Day5】软硬链接 文件存储,删除,目录管理命令
PVE 直通硬盘到TrueNAS
入门文档03 区分开发与生产环境(生产环境才执行‘热更新’)
spark算子-textFile算子
[Pytorch study notes] 8. How to use WeightedRandomSampler (weight sampler) when the training category is unbalanced data
【机器学习】1单变量线性回归
spark operator-wholeTextFiles operator