Day2
slice
str.slice(-3); //截取后三个字符,str不变
eg:Write a function maskify,which changes all but the last four characters into '#'.
maskify("4556364607935616") == "############5616"
程序:
function maskify(cc) {
return cc.slice(0, -4).replace(/./g, '#') + cc.slice(-4);
}
. 匹配所有的除了/n
/g 全局匹配
网友评论