SS
Size: a a a
SS
a
a
BK
BK
BK
SS
a
BK
a
SS
ʙ
a
var x2 = this.phone.replace(/\D/g,'').replace(/^7(\d{10})$/,'$1');
var x = x2.match( /^(\d{0,3})(\d{0,3})(\d{0,4})$/);
this.phone =
(x2.length==10?'7 ':'')
+ ( !x[2] ? x[l] : '(' + x[1] + ') ' + x[2] + (x[3]? '-' + x[3] : '') );
SS
BK
a
function test(phone){получаем
return (function(){
var x2 = this.phone.replace(/\D/g,'').replace(/^7(\d{10})$/,'$1');
var x = x2.match( /^(\d{0,3})(\d{0,3})(\d{0,4})$/);
this.phone =
(x2.length==10?'7 ':'')
+ ( !x[2] ? x[l] : '(' + x[1] + ') ' + x[2] + (x[3]? '-' + x[3] : '') );
return this.phone;}).call({ phone:phone });
}
console.dir(
['79000000000','9000000000','7 (900) 000-0000','(900) 000-0000']
.map(test)
);
0: "7 (900) 000-0000"
1: "7 (900) 000-0000"
2: "7 (900) 000-0000
3: "7 (900) 000-0000"
BK
a
a
x[l]
вместо x[1]
SS