<script>
//1.任意字符...
var reg1 = /.../;
console.log(reg1.test('a')); //false
console.log(reg1.test('aaaa')); //true
//2. \w 字母 数字 下划线
var reg2 = /\w\w/;
console.log(reg2.test('_a23'));
console.log(reg2.test('$3'));
//3. \s 任意空白字符 (制表符,回车符,换页符和丨)
var reg3 = /..\s../;
console.log(reg3.test("aa bb"));
console.log(reg3.test('aa bb'));
//4 \d 匹配数字,等同于[0-9]
var reg4 = /\d\d\d\d/;
console.log(reg4.test('9999'));
//5 \D 匹配非数字,等同于\[^0-9]
var reg5 = /\d\D\d/
console.log(reg5.test("hjsafsgjtuytue"));
console.log(reg5.test('4s4'));
//6. | 或匹配
var reg6 = /abc|xyz/;
console.log(reg6.test('dagdayurtsabcfyaifuysxyz'));
//7. [xyz] 表示包含xyz里面的任意一个,相当于x|y|z
var reg7 = /[abc]/;
console.log(reg7.test('a'));//true
console.log(reg7.test('iimooijoi'));//false
// [a-zA-Z] 匹配所偶有的大小写字母 [0-9]相当于\d
//8. [^x] 匹配除“x”之外的所有字符,其中‘x’可以为任意字符
var reg8 = /[^s]/;
console.log(reg8.test('dsadafafa'));//true
console.log(reg8.test('sssssss'));//false
//9.[^xyz]
var reg9 = /[^abc]/;
console.log(reg9.test('a'));//false
console.log(reg9.test('ooimoioihoi'));//true
//10. ^ 匹配字符串的开始
var reg10=/^1\d\d\d\d\d\d\d\d\d\d$/; //11个数字
console.log(reg10.test('13822222222'));
console.log(reg10.test('24353456436573'));
//11. $ 匹配字符串的结束
//12. \ 转义字符
var reg12=/\.com/;
console.log(reg12.test('acom'));
console.log(reg12.test('fafahfgf.com'));
//13. ? 重复出现零次或一次
var reg13=/^https?/;
console.log(reg13.test('http:ihfaifhaifhakfahj'));
console.log(reg13.test('https://dafasfasfafa'));
//14. + 重复出现一次或多次
var reg14=/a+/;
console.log(reg14.test('hfkjsfahfha'));
console.log(reg14.test('ohkookhokooi'));
//15. * 重复出现零次或多次
var reg15=/^https?.*/;
console.log(reg15.test('http:fhajysfte'));
//16. {n} 重复出现n次
var reg16=/^1\d{10}$/;
console.log(reg16.test('12'));
//17. {n,} 至少重复出现n次
var reg17=/^1\d{10,}/
//18.{m,n} 重复出现m到n次,其中m<n
var reg=/\d{m,n}/
</script>