URL
匹配多个子域名和无http或者https或者www (推荐)
[a-zA-z]+(://)*[^\s]*
已经验证的url如下:
open.weixin.qq.com
www.baidu.com
http://weixin.qq.com?rere=fa
http://www.ccgp.gov.cn
https://www.creditchina.gov.cn
https://open.weixin.qq.com?weixin=1
http://open.weixin.qq.com?weixin=1&xxx=%FE%RE
版本一
(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]
IP地址、前后有汉字、带参数,都能匹配。缺点:类似 www.oxoox.com 不带协议的匹配不到。
版本二 (推荐)
(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Za-z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Za-z0-9+&@#/%=~_|$?!:,.])*(?:\([-A-Za-z0-9+&@#/%=~_|$?!:,.]*\)|[A-Za-z0-9+&@#/%=~_|$])
上面的改进版。
版本三
(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?
手机号
手机号隐藏中间四位
var tel = "13122223333";
var reg = /^(\d{3})\d{4}(\d{4})$/;
tel = tel.replace(reg, "$1****$2");
console.log(tel);