微信小程序 wxs、js使用正则替换字符串


案例

把 2020-8-3 18:18:23 中的 - 替换为.

js

var str ='2020-8-3 18:18:23';
str.replace(new RegExp('-','g'),'.');



str.replace(/-/g,'.');

wxs

var str ='2020-8-3 18:18:23';
str.replace(getRegExp('-','g'),'.');

输出为

2020.8.3 18:18:23

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM