Skip to content

Instantly share code, notes, and snippets.

@JSoon
Last active May 17, 2018 01:30
Show Gist options
  • Save JSoon/fe42922b06f497919cfe838b995c56b9 to your computer and use it in GitHub Desktop.
Save JSoon/fe42922b06f497919cfe838b995c56b9 to your computer and use it in GitHub Desktop.
正则表达式
// 中文字符集(简体、繁体、双字节字符)
var regExp = /[\u4e00-\u9fa5x00-xff]/g;
// 中国大陆手机号码
var regExp = /^1[0-9]{10}$/; // 一般情况
var regExp = /^1[3|4|5|7|8][0-9]{9}$/; // 目前精确情况,电信,移动,联通目前发行的号码(截止2018年1月5日)
// 替换11位手机号中间4位
var mobileNumber = '13512345678';
mobileNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1 **** $2'); // 135 **** 5678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment