当前位置:网站首页>String number with special style
String number with special style
2022-06-12 02:17:00 【SultanST】
let str = 'haj123sdk54hask33dkhalsd879';
let str1 = 'haj123sdk54hask33dkhalsd879';
function findNum (str) {
return str.match(/\d+/g);
}
let arr2 = findNum(str).map(item => {
let st= "<span class='colorBlue'>" + item + "</span>"
str1 = str1.replace(item,st )
return str1
})
console.log(arr2[arr2.length-1])
// haj<span class='colorBlue'>123</span>sdk<span class='colorBlue'>54</span>hask<span class='colorBlue'>33</span>dkhalsd<span class='colorBlue'>879</span>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
'haj123sdk54hask33dkhalsd879'.replace(/\d+/g,s => `<span class='highlight'>${s}</span>`)
- 1.
The whole match
// The following example is to replace consecutive numbers with strings num
// RegExp(/\d+/g,'num')
let str =“12333”
// Replace all matches :
let str2 =str.replace(/3/g,"2")
- 1.
- 2.
- 3.
- 4.
- 5.
边栏推荐
- 力扣解法汇总883-三维形体投影面积
- MySQL advanced knowledge points
- Navicat for MySQL 11 Linux 破解方法
- 力扣解法汇总449-序列化和反序列化二叉搜索树
- Ozzanmation action system based on SSE
- How WPS inserts a directory and the operating steps for quickly inserting a directory
- 力扣解法汇总713- 乘积小于 K 的子数组
- The establishment and introduction of the announcement module of PHP development blog system
- Several common instructions for virsh to create / shut down / stop virtual machines
- The most comprehensive redis transaction control in 2022 (with illustration)
猜你喜欢

Knowledge points of mall development

Add sequence number column to MySQL query result set

CVPR2022 | iFS-RCNN:一种增量小样本实例分割器

Implementation scheme of iteration and combination pattern for general tree structure

el-upload上传文件

Almost all schools will ask for the second round exam! Come in and recite the answer!

Summary of concrete (ground + wall) + Mountain crack data set (classification and target detection)

Does the virtual host have independent IP

2022最全面的Redis事务控制(带图讲解)

El upload upload file
随机推荐
How to maximize the use of various matching methods—— Google SEM
力扣解法汇总944-删列造序
Graphical data analysis | business analysis and data mining
Force deduction solution summary 875- coco who likes bananas
Force deduction solution summary 933- number of recent requests
入手Ticwatch2
Force deduction solution summary 824 goat Latin
Graphic data analysis | data cleaning and pretreatment
2022 western style pastry (technician) recurrent training question bank and online simulated examination
ACL 2022 - strong combination of pre training language model and graphic model
Force deduction solution summary 1022- sum of binary numbers from root to leaf
Force deduction solution summary 668- the smallest number k in the multiplication table
Summary of force deduction method 417- Pacific Atlantic current problems
力扣解法汇总417-太平洋大西洋水流问题
Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?
力扣解法汇总396-旋转函数
打包一个包含手表端应用的手机端APK应用—Ticwear
Start ticwatch2
Several common instructions for virsh to create / shut down / stop virtual machines
ozzanimation-基於sse的動作系統