\d
\d\d
[a-z]
什么是正则表达式:用于记录文本规则的代码
正则表达式的作用:
① 可以匹配文本,表单验证(手机号码、邮箱、qq号码)
② 赛选网页内容(网络爬虫),meijob
③ 内容替换
正则表达式历史:
正则的组成内容:
① 普通字符内容
② 组成字符
③ 特殊字符
④ 限制字符
1 正则表达式---普通字符组成
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html> 3 <head> 4 <title>17-正则简单使用</title> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <meta name="description" content="" /> 7 <meta name="keywords" content="" /> 8 9 <script type="text/javascript"> 10 //正则表达式简单使用 11 12 //var reg = /正则表达式内容/; 13 var reg = /wo/; 14 15 var str = "hello world"; 16 17 //具体匹配 18 //被匹配目标内容.match(正则); 19 var rst = str.match(reg); 20 console.log(rst); 21 22 </script> 23 24 <style type="text/css"> 25 </style> 26 </head> 27 28 29 <body> 30 </body> 31 </html>