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----如何把一个字符串的大小写取反(大写变小写或小写变大写)
猜你喜欢
转载自blog.csdn.net/yangling_123/article/details/104872973
今日推荐
周排行