当前位置:网站首页>One problem encountered:
One problem encountered:
2022-07-24 13:42:00 【Green ear~】
use js Process the contained string into an array containing these numbers ?
answer :
One 、 Use regular : for example
var str ="d567unt7jk80o9hkghftjs123ldka78sdassdfd653";
str.match(/\d+/g);//["567", "7", "80", "9", "123", "78", "653"]
Two 、 The other is not regular , Can you write it down , For guidance
function test(str){
var ret = [];
var isNum = false;
for(var i = 0, iLen = str.length; i < iLen; i++){
var charCode = str.charCodeAt(i);
if(charCode >= 48 && charCode <= 57){
if(isNum){
ret[ret.length - 1] += str[i];
}else{
ret.push(str[i]);
}
isNum = true;
}else{
isNum = false;
}
}
return ret;
}
test('d567unt7jk80o9hkghftjs123ldka78sdassdfd653');
边栏推荐
- Flink容错机制(五)
- CSDN garbage has no bottom line!
- Network security - file upload content check bypass
- Common OJ questions of stack and queue
- Group knowledge map: distributed knowledge transfer and federated map reasoning
- 数据修改修改
- 通配符(泛域名)SSL证书
- Simple use and difference of symmetric res, AES and asymmetric RSA (JWT)
- 汉字风格迁移篇---用于汉字多字体生成的多样性正则化StarGAN
- HCIP第十三天
猜你喜欢

【无标题】

From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"

网络安全——文件上传白名单绕过

Thread multithreading

Chapter VI bus

Flex layout
![[acm/ two points] two points clear entry-level explanation](/img/87/e4d58b7530bfc381ec07d7c76e90a1.png)
[acm/ two points] two points clear entry-level explanation

Network security - file upload competitive conditions bypass

游戏思考04总结:针对帧、状态、物理同步的总结(之前写的太长,现在简略下)

Overview of multi view learning methods based on canonical correlation analysis
随机推荐
R语言epiDisplay包的kap函数计算Kappa统计量的值(总一致性、期望一致性)、对多个评分对象的结果进行一致性分析、评分的类别为多个类别、如果评分中包含缺失值则标准误及其相关统计量则无法计算
From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
Simple use and difference of symmetric res, AES and asymmetric RSA (JWT)
rhcsa第六次笔记
Flink容错机制(五)
Statistical table of competition time and host school information of 2022 national vocational college skills competition (the second batch)
Network security - file upload penetration test
How to verify the domain name after applying for SSL digital certificate?
Explain flex layout in detail
JQ remove an element style
Chrome plug-in development tutorial
Chat room project
网络安全——Web渗透测试
Notes on Linear Algebra -- lesson 25 -- projection of vectors on axes
软链接、硬链接
一些简单命令
从云原生到智能化,深度解读行业首个「视频直播技术最佳实践图谱」
【无标题】
如何用WebGPU流畅渲染百万级2D物体?
Solution to embedded SD card /u disk read-only problem (fat read-only repair method)