let str = "adsfsgEREvg啦啦啦啦啦dfsfr";
str = str.replace(/[a-zA-Z]/g,content=>{
console.log(content)
// content=>每一次正则匹配的结果
return content.toUpperCase()===content?content.toLowerCase():content.toUpperCase()
})
console.log(str)//=>ADSFSGereVG啦啦啦啦啦DFSFR
2020面试准备12----如何把一个字符串的大小写取反(大写变小写或小写变大写)
最新推荐文章于 2021-09-15 00:04:29 发布