替换

2023-10-25  本文已影响0人  xueyueshuai
let str = '12345678'.replace('1234', 'aaaa')
// str 为 'aaaa-56-78'
let str = '12345678'.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3')
// str 为 '1234-56-78'
上一篇 下一篇

猜你喜欢

热点阅读