当前位置:网站首页>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
边栏推荐
- Remote sensing image classification and recognition system based on convolutional neural network
- uni-app 原生APP-云打包集成极光推送(JG-JPUSH)详细教程
- 【每日一题】棋盘问题
- SSM框架系列——注解开发day2-2
- 免费试用一个月的服务器,并附上教程
- Zigbee之CC2530最小系统及寄存器配置(1)
- BUUCTF WEB [GXYCTF2019]禁止套娃
- Resolve disagrees about version of symbol device_ create
- [unity note] basic lighting in l4unity
- Source code analysis of synchronousqueue
猜你喜欢
没有空闲服务器?导入 OVF 镜像快速体验 SmartX 超融合社区版
世界读书日:我想推荐这几本书
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
22. 括号生成
力扣刷题之完全二叉树的节点个数
Introduction to metalama 4 Use fabric to manipulate items or namespaces
Object. The disorder of key value array after keys
CGC: contractual graph clustering for community detection and tracking
A graphic designer's fantasy world | ones characters
Use source insight to view and edit source code
随机推荐
leetcode-791. Custom string sorting
If you were a golang interviewer, what questions would you ask?
PHP generates JSON to process Chinese
4.DRF 权限&访问频率&过滤&排序
8 websites that should be known for product development to enhance work experience
BUUCTF WEB [BJDCTF2020]The mystery of ip
将新增和编辑的数据同步更新到列表
STM32 control stepper motor (ULN2003 + 28byj)
[daily question] chessboard question
Aviation core technology sharing | overview of safety characteristics of acm32 MCU
21 天学习MongoDB笔记
ZigBee CC2530 minimum system and register configuration (1)
Trier les principales utilisations de l'Agent IP réseau
Fashion cloud learning - input attribute summary
Kubernetes 入門教程
No idle servers? Import OVF image to quickly experience smartx super fusion community version
22. Bracket generation
如何实现点击一下物体播放一次动画
Remote sensing image classification and recognition system based on convolutional neural network
Number of nodes of complete binary tree