实现电话号码的匹配
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test14</title>
<script>
var abb = "16782367826";
var pp = /^1[3-9][0-9]{9}$/;
console.log(pp.test(abb));
</script>
</head>
<body>
</body>
</html>
实现 去除数据两端的所有空格
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test14</title>
<script>
// 要求是去除两端的空格
var str = " as aa bb ";
// var str = str.replace(/^\s*|\s*$/g,"");//实现删除两端空格,保留中间的空格
var str = str.replace(/\s*/g,"");//实现删除所有的空格
console.log(str);
</script>
</head>
<body>
</body>
</html>
邮件匹配
var emailReg = /^\w{3,}(\.\w+)*@[A-z0-9]+(\.[A-z]{2,5}){1,2}$/;
var email = "abchello@163.com";
console.log(emailReg.test(email));