Correction status:qualified
Teacher's comments:完成的不错
一.原子
<?php echo '<h2>1.普通字符</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >a-z</td><td >匹配单个小写字母</td></tr>'; echo '<tr align="center" ><td>A-Z</td><td>匹配单个大写字母</td><tr>'; echo '<tr align="center" ><td>0-9</td><td>匹配单个数字</td><tr>'; echo '</table>'; echo '<h3>匹配小写字母,大写字母和数字</h3>'; $pattem='/(b)|(A)|(5)/'; $subject = '11112222333344445555666677778888999900000 aaabbbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " {// 输出匹配次数}",print_r($a); echo '<br>'; echo " {// 输出匹配结果}".'<pre>',print_r($data, true);
<?php echo '<h2>3.自定义字符</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[1234]</td><td >匹配1、2、3、4数字</td></tr>'; echo '<tr align="center" ><td>[0-9]</td><td> 匹配数字集合</td><tr>'; echo '<tr align="center" ><td>[a-z]</td><td> 匹配小写字母集合</td><tr>'; echo '<tr align="center" ><td>[A-Z]</td><td>匹配大写字母集合</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]</td><td>匹配数字、小写字母、大写字母集合</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/([a-z]|[A-Z])/'; $subject = '111122223333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
二.量词字符
元字符是修饰原子字符的,可以理解为原子的定语或限定条件
元字符不允许单独使用,必须配合原子,共同工作
"." 匹配除换行符之外的任意一个字符
<?php echo '<h2>" . "匹配除换行符之外的任意一个字符</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >21.</td><td >匹配两个数字,在加任意一个字符</td></tr>'; echo '<tr align="center" ><td>aa.</td><td> 匹配两个小写字母,在加任意一个字符</td><tr>'; echo '<tr align="center" ><td>OU.</td><td> 匹配两个大写字母,在加任意一个字符</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/2./'; $subject = '111121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>" | " 匹配2个或多个分支</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >1|2</td><td >匹配1和2</td></tr>'; echo '<tr align="center" ><td>a|b</td><td> 匹配a和b</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/a|b./'; $subject = '111121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"[ ] "匹配方括号内指定的任意一个原子</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[1234]</td><td >匹配1、2、3、4数字</td></tr>'; echo '<tr align="center" ><td>[0-9]</td><td>匹配数字集合</td><tr>'; echo '<tr align="center" ><td>[a-z]</td><td>匹配小写字母集合</td><tr>'; echo '<tr align="center" ><td>[A-Z]</td><td>匹配大写集合</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]</td><td>匹配数字、小写字母、大写字母集合</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-9a-zA-Z]/'; $subject = '111121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"[^] " 匹配除方括号内指定原子以外的任意一个原子</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[^1234]</td><td >匹配去除1、2、3、4数字</td></tr>'; echo '<tr align="center" ><td>[^0-9]</td><td>匹配去除数字集合</td><tr>'; echo '<tr align="center" ><td>[^a-z]</td><td>匹配去除小写字母集合</td><tr>'; echo '<tr align="center" ><td>[^A-Z]</td><td>匹配去除大写集合</td><tr>'; echo '<tr align="center" ><td>[^0-9a-zA-Z]</td><td>匹配去除数字、小写字母、大写字母集合</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[^0-9a-zA-Z]/'; $subject = '111121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"^ " 匹配字符串开始位置,一串字符串,必须从这里开始</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >^1</td><td >匹配从1数字开始</td></tr>'; echo '<tr align="center" ><td >^[0-9]</td><td >匹配从数字集合开始</td></tr>'; echo '<tr align="center" ><td>^[a-z]</td><td> 匹配从小写字母集合开始</td><tr>'; echo '<tr align="center" ><td>^[A-Z]</td><td>匹配从大写字母集合开始</td><tr>'; echo '<tr align="center" ><td>^[0-9a-zA-Z]</td><td>匹配从数字、小写字母、大写字母集合开始</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/^[0-9]/'; $subject = '111121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"$" 匹配字符串结束位置</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]$</td><td > 匹配从数字集合结束</td></tr>'; echo '<tr align="center" ><td>[a-z]$</td><td> 匹配从小写字母集合结束</td><tr>'; echo '<tr align="center" ><td>[A-Z]$</td><td>匹配从大写字母集合结束</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]$</td><td>匹配从数字、小写字母、大写字母集合结束</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[a-z]$/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
三.量词(界定符)
<?php echo '<h2>"n"表示前面原子出现n次</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]{3}</td><td >匹配从数字连续出现3次</td></tr>'; echo '<tr align="center" ><td>[a-z]{3}</td><td>匹配从小写字母集合连续出现3次</td><tr>'; echo '<tr align="center" ><td>[A-Z]{3}</td><td>匹配从大写字母集合连续出现3次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]{3}</td><td>匹配从数字、小写字母、大写字母集合连续出现3次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]{3}/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"n."表示前面原子出现不少于n次</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]{1,}</td><td >匹配从数字连续出现1次或多次</td></tr>'; echo '<tr align="center" ><td>[a-z]{1,}</td><td>匹配从小写字母集合连续出现1次或多次</td><tr>'; echo '<tr align="center" ><td>[A-Z]{1,}</td><td>匹配从大写字母集合连续出现1次或多次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]{1,}</td><td>匹配从数字、小写字母、大写字母集合连续出现1次或多次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]{1,}/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"n,m"表表示前面原子至少出现n次,最多出现m次</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]{1,3}</td><td >匹配从数字连续出现1次或3次</td></tr>'; echo '<tr align="center" ><td>[a-z]{1,3}</td><td>匹配从小写字母集合连续出现1次或3次</td><tr>'; echo '<tr align="center" ><td>[A-Z]{1,3}</td><td>匹配从大写字母集合连续出现1次或3次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]{1,3}</td><td>匹配从数字、小写字母、大写字母集合连续出现1次或3次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]{1,3}/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"*"匹配0次、1次或多次前面原子</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]*</td><td >匹配从数字连续出现0次、1次或多次</td></tr>'; echo '<tr align="center" ><td>[a-z]*</td><td>匹配从小写字母集合连续出现0次、1次或多次</td><tr>'; echo '<tr align="center" ><td>[A-Z]*</td><td>匹配从大写字母集合连续出现0次、1次或多次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]*</td><td>匹配从数字、小写字母、大写字母集合连续出现0次、1次或多次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]*/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"+"匹配1次或多次前面原子</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]+</td><td >匹配从数字连续出现1次或多次</td></tr>'; echo '<tr align="center" ><td>[a-z]+</td><td>匹配从小写字母集合连续出现1次或多次</td><tr>'; echo '<tr align="center" ><td>[A-Z]+</td><td>匹配从大写字母集合连续出现1次或多次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]+</td><td>匹配从数字、小写字母、大写字母集合连续出现1次或多次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]+/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"?"匹配0次或1次前面原子</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>示例</th><th>描述</th></tr>'; echo '<tr align="center" ><td >[0-9]?</td><td >匹配从数字连续出现0次或1次</td></tr>'; echo '<tr align="center" ><td>[a-z]?</td><td>匹配从小写字母集合连续出现0次或1次</td><tr>'; echo '<tr align="center" ><td>[A-Z]?</td><td>匹配从大写字母集合连续出现0次或1次</td><tr>'; echo '<tr align="center" ><td>[0-9a-zA-Z]?</td><td>匹配从数字、小写字母、大写字母集合连续出现0次或1次</td><tr>'; echo '</table>'; echo '<h3>代码示例:</h3>'; $pattem ='/[0-3]?/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
四.预定义字符
<?php echo '<h2>"\d"\d 匹配任意一个十进制数===等价于 [0-9]</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\d/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\D"匹配任意一个除十进制以外的字符===等价于 [^0-9]</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\D/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\w" 匹配任意一个字母/数字/下划线字符===等价于 [0-9a-zA-Z_]</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\w/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\W" 匹配任意一个字母/数字/下划线之外的字符===等价于 ^[0-9a-zA-Z_]</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\W/'; $subject = '1151121234522322233121113333444455556666777788889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\s" 匹配任意一个空白字符(非打印)</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\s/'; $subject = '11511212345223222331211 133334 444555566667777 88889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\S 匹配任意一个空白字符以外的字符</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\S/'; $subject = '11511212345223222331211 133334 444555566667777 88889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\b"匹配单词边界</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\b/'; $subject = '11511212345223222331211 133334 444555566667777 88889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2>"\B"匹配单词边界以外的部分</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\B/'; $subject = '11511212345223222331211 133334 444555566667777 88889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
五.特殊字符
特殊字符需要在符号前面增加\转义
需转义符号: \ * + ? . | ^ $ [ ] ( )
<?php echo '<h2>特殊字符需要在符号前面增加\转义--转义符号: \ * + ? . | ^ $ [ ] ( )</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/\+/'; $subject = '11511212345223222331211 133334 444555566667777 88* + ? . | ^ $ [ ] ( ) 889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
六.分组符
( ) 匹配其整体为一个原子[模式单元],即多个原子组成的大原子
七.界定符
/ / 符号是正则表达式的界定符,里面包裹正则表达式
八.修正符(在界定符后面)
多个修正符可以组合在一起使用
( U ) 表示取消贪婪模式
正则表达式有:贪婪模式和懒惰模式
正则表达式默认是贪婪模式
<?php echo '<h2>正则表达式默认是贪婪模式</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/ab.+/'; $subject = '11511212345223222331211 133334 444555566667777 88* + ? . | ^ $ [ ] ( ) 889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true); <?php echo '<h2>正则表达式懒惰模式</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/ab.+/U'; $subject = '11511212345223222331211 133334 444555566667777 88* + ? . | ^ $ [ ] ( ) 889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2> "i "表示和模式进行匹配时忽略大小写</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/ab/i'; $subject = '1151121234522322CC2331211AABBD 133334 444555566667777 88* + ? . | ^ $ [ ] ( ) 889999000tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2> "s "被匹配的字符串将视为一行来看,包括换行符,换行符将被视为普通字符串</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/ab/s'; $subject = '11511ssasab2123aaa4522322CC2331211AABBD 133334 444555566 667777 88* + ? . | ^ $ [ ] ( ) aaaaa88999900ab0tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
<?php echo '<h2> "x "模式中的空白忽略不计</h2>'; echo '<h3>代码示例:</h3>'; $pattem ='/a b ./s'; $subject = '11511ssasab2123aaa4522322CC2331211AABBD 133334 444555566 667777 88* + ? . | ^ $ [ ] ( ) aaaaa88999900ab0tablebbcccdddeeefffggghhhiiijjjjkkkk'; $a = preg_match_all($pattem,$subject,$data); echo " 输出匹配次数:",print_r($a); echo '<br>'; echo " 输出匹配结果:".'<pre>',print_r($data, true);
九.正则表达式优先级(1级最大)
echo '<h2>正则表达式优先级(1级最大)</h2>'; echo '<table border="1" cellspaceing="1" cellpadding="9" align=:center" width=50%>'; echo '<tr align="center" bgcolor="#007b89" style="color:#fff"><th>级别</th><th>符号</th><th>解释</th></tr>'; echo '<tr align="center" ><td >1</td><td >\</td><td >转义字符</td></tr>'; echo '<tr align="center" ><td >2</td><td >( )、 ( ?: )、 ( ?= )、 [ ]、</td><td >模式单元与原子表</td></tr>'; echo '<tr align="center" ><td >3</td><td >*、 +、 ?、 {n}、 {n,}、 {n,m}</td><td >重复匹配</td></tr>'; echo '<tr align="center" ><td >4</td><td >^、 $、 \b、 \B</td><td >边界匹配</td></tr>'; echo '<tr align="center" ><td >5</td><td >|</td><td >模式选择</td></tr>'; echo '</table>';