微信小程序 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
原文地址:https://www.cnblogs.com/lyso/p/13427952.html