^[0-9]*$n位的数字:^\d{n}$至少n位的数字:^\d{n,}$m-n位的数字:^\d{m,n}$零和非零开头的数字:^(0|[1-9][0-9]*)$非零开头的最多带两位小数的数字:^([1-9][0-9]*)+(.[0-9]{1,2})?$带1-2位小数的正数或负数:^(\-)?\d+(\.\d{1,2})?$正数、负数、和小数:^(\-|\+)?\d+(\.\d+)?$有两位小数的正实数:^[0-9]+(.[0-9]{2})?$有1~3位小数的正实数:^[0-9]+(.[0-9]{1,3})?$非零的正整数:^[1-9]\d*$ 或 ^([1-9][0-9]*){1,3}$ 或 ^\+?[1-9][0-9]*$非零的负整数:^\-[1-9][]0-9"*$ 或 ^-[1-9]\d*$
非負整數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\d $</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[1-9]\d*|0$</span>
非正整數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^-[1-9]\d*|0$ </span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^((-\d )|(0 ))$</span>
非負浮點數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\d (\.\d )?$</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0? \.0 |0$</span>
非正浮點數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^((-\d (\.\d ) ?)|(0 (\.0 )?))$</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(-([1-9]\d*\.\d* |0\.\d*[1-9]\d*))|0?\.0 |0$</span>
正浮點數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^[1-9]\d*\.\d *|0\.\d*[1-9]\d*$</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^(([0-9] \.[0-9 ]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9] )|([0-9]*[ 1-9][0-9]*))$</span>
負浮點數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^-([1-9]\d*\. \d*|0\.\d*[1-9]\d*)$</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(-(([0-9] \ .[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9] )|([0 -9]*[1-9][0-9]*)))$</span>
浮點數:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^(-?\d )(\.\d )? $</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^-?([1-9]\d*\.\d*|0\.\d*[1-9]\ d*|0?\.0 |0)$</span>
#漢字##:^[\u4e00-\u9fa5]{0,}$<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;"></span>
#
英文和數字:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#^[A-Za-z0-9] $</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[A-Za-z0-9]{4,40}$</span>
長度為3-20的所有字元:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^.{3,20}$ </span>
由26個英文字母組成的字串:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[A-Za-z ] $</span>
由26個大寫英文字母組成的字串#:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[A-Z] $</span>
另外,搜尋公眾號Java後端堆疊後台回覆「私活」,取得一份驚喜禮包。
由26個小寫英文字母組成的字串#:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[a-z] $</span>
由數字和26個英文字母組成的字串#:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[A-Za -z0-9] $</span>
由數字、26個英文字母或底線組成的字串#:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\w $ 或^\w{3,20}</span>
中文、英文、數字包含底線:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[\u4E00-\u9FA5A-Za -z0-9_] $</span>
中文、英文、數字但不包括底線等符號#:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[\u4E00- \u9FA5A-Za-z0-9] $</span>
或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[\u4E00-\u9FA5A-Za-z0-9]{2,20}$</span>
可以輸入含有<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^%&',;=?$\"</span>
#等字元:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">[^%&',;=?$\x22] </span>
禁止輸入含有~的字元 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">[^~\x22] </span>
.*匹配除 \n 以外的任何字符。/[\u4E00-\u9FA5]/ 汉字/[\uFF00-\uFFFF]/ 全角符号/[\u0000-\u00FF]/ 半角符号
Email 地址:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$</span>
[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(/.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+/.?
[a-zA-z]+://[^\s]* 或 ^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$
^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
电话号码(“XXX-XXXXXXX”、”XXXX-XXXXXXXX”、”XXX-XXXXXXX”、”XXX-XXXXXXXX”、”XXXXXXX”和”XXXXXXXX):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(\(\d{3,4}-)|\d{3.4}-)?\d{7,8}$</span>
国内电话号码(0511-4405222、021-87888822):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">\d{3}-\d{8}|\d{4}-\d{7}</span>
身分證字號(15位元、18位數字):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\d{15}|\d{18}$</span>
短身分證號碼(數字、字母x結尾):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^([0-9]){7,18}(x|X)?</span>
$ 或 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^\d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$</span>
帳號是否合法(字母開頭,允許5-16字節,允許字母數字下劃線):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[a-zA-Z][a-zA-Z0- 9_]{4,15}$</span>
密碼(以字母開頭,長度在6~18之間,只能包含字母、數字和底線): <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[a-zA-Z]\w{5,17}$</span>
強密碼(必須包含大小寫字母和數字的組合,不能使用特殊字符,長度在8-10之間):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(?=.*\d )(?=.*[a-z])(?=.*[A-Z]).{8,10}$</span>
##日期格式: ^\d{4}-\d{1,2}-\d{1,2}<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;"></span>
一年的12個月(01~09和1~12):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(0?[1-9]|1[0-2])$</span>
一個月的31天(01~09和1~31):<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^((0?[1-9])| ((1|2)[0-9])|30|31)$</span>
有四種錢的表示形式我們可以接受:”10000.00” 和“10,000.00”, 和沒有“分” 的“10000” 和“10,000”:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[1-9][0-9]*$</span>
這表示任意一個不以0開頭的數字,但是,這也意味著一個字元”0”不通過,所以我們採用下面的形式:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(0 |[1-9][0-9]*)$</span>
一個0或一個不以0開頭的數字.我們也可以允許開頭有一個負號: <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^(0|-?[1-9][0-9]*)$</span>
4.這表示一個0或一個可能為負的開頭不為0的數字.讓用戶以0開頭好了.把負號的也去掉,因為錢總不能是負的吧.下面我們要加的是說明可能的小數部分:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[0-9] (.[0-9] )?$</span>
必須說明的是,小數點後面至少應該有1位數,所以」10.」是不通過的,但是「10」 和「10.2」 是通過的:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[0- 9] (.[0-9]{2})?$</span>
這樣我們規定小數點後面必須有兩位,如果你認為太苛刻了,可以這樣:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[0-9] (.[0-9]{1 ,2})?$</span>
這樣就允許用戶只寫一位小數.下面我們該考慮數字中的 <span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">#逗號</span>
了,我們可以這樣:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^[0-9]{1,3}(,[0-9]{3})*(.[0-9]{1,2})?$</span>
1到3个数字,后面跟着任意个 逗号+3个数字,逗号成为可选,而不是必须:<span mp-original-font-size="16" mp-original-line-height="25" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 25px;">^([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(.[0-9]{1,2})?$</span>
备注:这就是最终结果了,别忘了+可以用*替代如果你觉得空字符串也可以接受的话(奇怪,为什么?)最后,别忘了在用函数时去掉去掉那个反
xml文件:^([a-zA-Z]+-?)+[a-zA-Z0-9]+\.[x|X][m|M][l|L]$
中文字符的正则表达式:[\u4e00-\u9fa5]
雙位元組字元:^\x00-\xff)
#空白行的正規表示式:\n\s*\r (可以用來刪除空白行)
HTML標記的正規表示式:<(\S?)[^>]>.?\ 1>|<.? /> (網上流傳的版本太糟糕,上面這個也僅僅能部分,對於復雜的嵌套標記依舊無能為力)
首尾空白字元的正規表示式:^\s|\s
#) (可以用來刪除行首行尾的空白字元(包括空格、製表符、換頁符等等),非常有用的表達式)
騰訊QQ號:[1-9][0-9]{4,}(騰訊QQ號從10000開始)
中國郵遞區號:[1 -9]\d{5}(?!\d)(中國郵遞區號為6位數字)
#IP位址:\d .\d .\d .\d (提取IP位址時有用)
IP地址:((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d))
牛逼啊!接私活必备的 N 个开源项目!赶快收藏吧
IP-v4地址:\b(?:(?: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]?)\b (提取IP地址时有用)
校验IP-v6地址:
(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))
子网掩码:
((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))
校验日期:
^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$(“yyyy-mm-dd“ 格式的日期校验,已考虑平闰年。)
抽取注释:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;"><!--(.*?)--></span>
查找CSS属性:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">^\\s*[a-zA-Z\\-]+\\s*[:]{1}\\s[a-zA-Z0-9\\s.#]+[;]{1}</span>
提取頁面超連結:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">(<a\\s*(?!.*\\brel=)[^>]*)(href="https ?:\\/\\/)((?!(?:(?:www\\.)?'.implode('|(?:www\\.)?', $follow_list).'))[ ^" rel="external nofollow" ] )"((?!.*\\brel=)[^>]*)(?:[^>]*)></span>
#提取網頁圖片:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">\\< *[img][^\\\\>]*[src] *= *[\\"\\' ]{0,1}([^\\"\\'\\ >]*)</span>
另外,搜尋公眾號GitHub猿後台回覆“賺錢”,獲取一份驚喜禮包。
提取網頁顏色代碼:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">^#([A-Fa-f0-9]{6}|[A-Fa-f0-9 ]{3})$</span>
檔案副檔名效驗:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">^([a-zA-Z]\\:|\\\\)\\\\([^\\\\] \\\\)*[^\\/:*?"<>|] \\.txt(l)?$</span>
判斷IE版本:<span mp-original-font-size="16" mp-original-line-height="28" style="margin: 0px;padding: 0px;outline: 0px;max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;font-size: 16px;overflow-wrap: break-word !important;line-height: 28px;">^.*MSIE [5-8](?:\\.[0-9] )?(?!.*Trident\\/[5-9]\\.0). *$</span>
############################ ### ###
以上是維運必備,正規表示式超全速查手冊,趕快收藏!的詳細內容。更多資訊請關注PHP中文網其他相關文章!