1. Mobile phone number
(1) Regular Match
if (!/^1[3|4|5|6|7|8|9]\d{9}$/.test(13807999985)) { (resultPhone);//138****9985
(2) Substr intercept
var phone = "17610603529"; var mphone = (0, 3) + "****" + (7); // If you use the Es6 template string, you can do not use the + sign for splicing var phone = "17610603529"; var mphone = `${(0, 3)}****${(7)}`; (mphone);
2. Name
(1) Substr intercept
activated() { (("Tortoise belly")); // king** }, methods: { formatName(name) { let newStr; if ( === 2) { newStr = (0, 1) + "*"; //Seave the string from bit 0 by substr, and intercept 1 } else if ( > 2) { // When the name is greater than 2 digits let char = ""; for (let i = 0, len = - 2; i < len; i++) { // Loop through strings char += "*"; } newStr = (0, 1) + char + (-1, 1); } else { newStr = name; } return newStr; }, },
This is the article about the implementation of the encryption display function of Vue mobile phone number regular matching name. For more related content of Vue mobile phone number regular matching, please search for my previous article or continue browsing the related articles below. I hope everyone will support me in the future!