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)