该特性是非标准的,请尽量不要在生产环境中使用它!
- 非标准$1, $2, $3, $4, $5, $6, $7, $8, $9 属性是包含括号子串匹配的正则表达式的静态和只读属性。
- 这些属性可以在String.replace 方法中替换字符串. 在这种情况下, 不用在前面加上RegExp。
例:
var re = /(\w+)\s(\w+)/;
var str = 'John Smith';
str.replace(re, '$2, $1'); // "Smith John"
RegExp.$1; // "John"
RegExp.$2; // "Smith"
通用时间转换方法
export function formatDate(oldDate, fmt) {
let date = new