1、匹配一串字符串中的手機號碼
arr.match(/((((13[0-9])|(15[^4])|(18[0,1,2,3,5-9])|(17[0-8])|(147))\d{8})|((\d3,4|\d{3,4}-|\s)?\d{7,14}))?/g);
2、刪除對象中的某個元素
delete obj.phone;
3、刪除數組中指定的元素
Array.prototype.indexOf = function (val) { //prototype 給數組添加屬性
for (var i = 0; i < this.length; i++) { //this是指向數組,this.length指的數組類元素的數量
if (this[i] == val) return i; //數組中元素等於傳入的參數,i是下標,如果存在,就將i返回
}
return -1;
};
Array.prototype.remove = function (val) { //prototype 給數組添加屬性
var index = this.indexOf(val); //調用index()函數獲取查找的返回值
if (index > -1) {
this.splice(index, 1); //利用splice()函數刪除指定元素,splice() 方法用於插入、刪除或替換數組的元素
}
}
arr.remove(obj)