<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>

            PHP常用正則表達式

            時間:2025-10-28 16:09:18 php語言

            PHP常用正則表達式

              header("Content-Type:text/html;charset=utf-8"),這一句一般都是用于設置頁面的字符集,防止出現亂碼,雖然跟本節沒多大關系,但也可以當作基礎知識。

              /pic/strong>

              1

              2

              3

              $preg = '/^(https?:/pic/i';

              $str = 'www.liqingbo.cn';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^([a-z]+):/pic/i';

              $str = '/pic/p>

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/';

              $str = '255.255.255.250';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              4

              $preg = '/^<([a-z]+)([^<]+)*(?:>(.*)</1>|s+/>)$/';

              $str = '<a href="/pic/a>';

              $res = preg_match_all($preg, $str, $matches);

              var_dump($matches);

              /pic/strong>

              1

              2

              3

              4

              5

              $preg = '/<img[^>]+(src="([^"<>']+)"|src='([^"<>']+)')[^<>]*>/';

              $html = '<div><a href="/pic/pic/src/img0.gif" /><img src="/pic/src/img1.gif" /></a></div>';

              $res = preg_match_all($preg, $html, $matches, PREG_PATTERN_ORDER);

              /pic/p>

              echo $matches[2][0]; /pic/p>

              /pic/strong>

              1

              2

              3

              $preg = '/^([a-z0-9_.-]+)@([a-z0-9.-]+).([a-z]+)$/i';

              $str = 'jeddy_liu-jin@gmail.com';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^[a-z0-9@_.-]{6,18}$/';

              $str = 'liujin@1234.com';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^[a-z0-9_-]{3,16}$/';

              $str = 'liujin-88';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^(0d{2,3})-?(d{7,8})$/';

              $str = '015-5415488';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^1[3|4|5|8]d{9}$/';

              $str = '18012345678';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/^[1-9]d{5}$/';

              $str = '415000';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              $preg = '/(^d{15}$)|(^d{18}$)/';

              $str = '430701198806520';

              echo preg_match($preg, $str);

              /pic/strong>

              1

              2

              3

              4

              $preg = '/^[x{4e00}-x{9fa5}]+$/u';

              $str = 'PHP博客';

              preg_match($preg, $str, $match);

              var_dump($match);


            【PHP常用正則表達式】相關文章:

            PHP常用的正則表達式11-06

            PHP知識:PHP常用正則表達式大全03-16

            PHP常用的正則表達式是什么02-26

            用php常用表單驗證的正則表達式02-27

            php漢字正則表達式12-08

            php正則表達式的基本語法總結12-02

            PHP知識:正則表達式基礎知識12-05

            php過濾HTML標簽、屬性等正則表達式02-22

            在PHP中使用正則表達式進行查找替換03-15

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看