当前位置:网站首页>Record a website for querying compatibility, string Replaceall() compatibility error
Record a website for querying compatibility, string Replaceall() compatibility error
2022-04-23 12:53:00 【ZMJ_ QQ】
Can I use... Support tables for HTML5, CSS3, etc
This website can be queried CSS、JS Compatibility in various versions of the browser
I came across one today String.replaceAll() Error reporting , Normal on my computer , Report an error after changing a computer , I thought it was a code problem at first , Later, I saw an article and found that it was caused by the browser version .
replaceAll Some lower versions of browsers are not supported , If you can't ensure the browser version in development , Try to use other alternatives replaceAll
Solution
1. utilize splite()
and join()
let str = '2021.01.25'// To convert it to 2021-01-25
console.log(str.split('.').join('-'))//2021-01-25
2. replace()
let str = '2021.01.25'// To convert it to 2021-01-25
console.log(str.replace(/\./g,'-'))//2021-01-25
replace The compatibility ratio of replaceAll good .replace() Take two parameters , The first parameter is the character to be replaced , Support regular , If you don't add regular g keyword , It means to replace the first matching string .
版权声明
本文为[ZMJ_ QQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230616456830.html
边栏推荐
- Web17 -- use of El and JSTL
- php生成json处理中文
- XinChaCha Trust SSL Organization Validated
- mysql中 innoDB执行过程分析
- PHP generates JSON to process Chinese
- Buuctf Web [bjdctf2020] zjctf, but so
- Luogu p5540 [balkanoi2011] timeismoney | minimum product spanning tree problem solution
- 0基础可以考CPDA数据分析师证书吗
- AD20补充笔记3—快捷键+持续更新
- 如何实现点击一下物体播放一次动画
猜你喜欢
SSL certificate refund instructions
Pre competition practice of TIANTI competition
8 websites that should be known for product development to enhance work experience
4. DRF permission & access frequency & filtering & sorting
Remote access to raspberry pie at home (Part 1)
云原生KubeSphere部署Redis
SSM框架系列——Junit单元测试优化day2-3
Unlock openharmony technology day! The annual event is about to open!
Servlet监听器&过滤器介绍
Packet capturing and sorting -- TCP protocol [8]
随机推荐
Common problems of unity (1)
Baserecyclerviewadapterhelper realizes pull-down refresh and pull-up loading
4.DRF 权限&访问频率&过滤&排序
Jiachen chapter Genesis "inner universe" joint Edition
Idea的src子文件下无法创建servlet
世界读书日:我想推荐这几本书
Bert base Chinese Download (SMART)
21 天学习MongoDB笔记
Analysis of InnoDB execution process in MySQL
Luogu p3236 [hnoi2014] picture frame solution
How to prevent the website from being hacked and tampered with
[wechat applet] Z-index is invalid
What are the forms of attack and tampering on the home page of the website
Zigbee之CC2530最小系统及寄存器配置(1)
Dialogue with Bruce, author of PostgreSQL: "changing careers" is to better move forward
31. 下一个排列
【蓝桥杯】4月17日省赛刷题训练(前3道题)
梳理網絡IP代理的幾大用途
Synchronously update the newly added and edited data to the list
Trier les principales utilisations de l'Agent IP réseau