Java的正則表達(dá)式講解:(為了能看清,本文正則表達(dá)式用中文的句號代替英文句點(diǎn))
[if !supportLists]1??? [endif]英文句點(diǎn)符號:匹配單個任意字符。
eg:
表達(dá)式”t。o? 可以匹配:tno,t#o,teo等等。不可以匹配:tnno,to,Tno,t正o等。
[if !supportLists]2??? [endif]方括號:只有方括號里面指定的字符才參與匹配,也只能匹配單個字符。
eg:
表達(dá)式:t[abcd]n? 只可以匹配:tan,tbn,tcn,tdn。不可以匹配:thn,tabn,tn等。
3? |符號。相當(dāng)與“或”,可以匹配指定的字符,但是也只能選擇其中一項進(jìn)行匹配。
?? eg:
?? 表達(dá)式:t(a|b|c|dd)n 只可以匹配:tan,tbn,tcn,tddn。不可以匹配taan,tn,tabcn
[if !supportLists]4??? [endif]表示匹配次數(shù)的符號
[if !vml]
[endif]
???? ???? {n, }表示至少N次。
eg:
表達(dá)式:[0—9]{ 3 }? \—[0-9]{ 2 }?\—[0-9]{ 3 } 的匹配格式為:999—99—999
因為“—”符號在正則表達(dá)式中有特殊的含義,它表示一個范圍,所以在前面加轉(zhuǎn)義字符“\”。
[if !supportLists]5??? [endif]^符號:表示否
^符號被稱為“否”符號,如果用在方括號內(nèi),“^“表示不想匹配的字符。
eg:
表達(dá)式:[^x] 第一個字符不能是x
6:圓括號,和空白符號
“\s”是空白符號,只可以匹配一個空格、制表符、回車符、換頁符,不可以匹配自己輸入的多個空格。
??? ()是分組號,可以用ORO API提取處出值,后面將詳細(xì)討論。
7:正則表達(dá)式的一些快捷符號:
??? \d表示[0—9],? \D表示[^0—9],? \w表示[0—9A—Z_a—z],
\W表示[^0—9A—Z_a—z],? \s表示[\t\n\r\f],??\S表示[^\t\n\r\f]
8? 一些常用的正則表達(dá)式:
Java:(([a-z]|_)(\\w*)){6,20}匹配以字母或下劃線開頭,字母數(shù)字下劃線結(jié)尾的字符串
JavaScript:/^(\-?)(\d+)$/匹配數(shù)字。/^\w+$/匹配字母數(shù)字下劃線。
.+ 一個或多個字符
/0 第一次匹配的字符串
[if !supportLists]9??? [endif]java類中使用正則表達(dá)式:
eg1:
Pattern p = Pattern.compile("t.n");
Matcher m =p.matcher(“ton”);
if(m.matches()){
??? return true;
}
eg2:booleanbool=Pattern.matches (“t.n”,”ton”);
如果一個正則表達(dá)式要重復(fù)利用,用第一種,如果只匹配一次,第二種是最佳選擇。
[if !supportLists]10 [endif]反斜線字符(‘\’)用于轉(zhuǎn)義字符,同時還可以引用非轉(zhuǎn)義字符(不包括非轉(zhuǎn)義字母)
因此‘\\’表示‘\’,‘\{’表示{。? 但是‘\y’就是錯的,因為在不表示轉(zhuǎn)義構(gòu)造的 任何字母字符前 使用反斜線都是錯誤的。
根據(jù) Java Language Specification的要求,Java 源代碼的字符串中的反斜線被解釋為 Unicode 轉(zhuǎn)義或其他字符轉(zhuǎn)義。因此必須在字符串字面值中使用兩個反斜線,表示正則表達(dá)式受到保護(hù),不被Java 字節(jié)碼編譯器解釋。例如,當(dāng)解釋為正則表達(dá)式時,字符串字面值 "\b" 與單個退格字符匹配,而 "\\b" 與單詞邊界匹配。字符串字面值 "\(hello\)" 是非法的,將導(dǎo)致編譯時錯誤;要與字符串(hello) 匹配,必須使用字符串字面值 "\\(hello\\)"。 注意:‘\b’是一個字符而‘\\b’是兩個字符
[if !supportLists]11 [endif]Pattern類
[if !supportLists](1)???????[endif]8種模式:比如啟用多行模式,啟用unix模式等,eg? int CASE_INSENSITIVE表示啟用不區(qū)分大小寫的模式。
[if !supportLists](2)???????[endif]4個靜態(tài)方法
兩個單例模式構(gòu)造器:
Pattern compile(String regex);
Pattern compile(String regex,int flags)flags為八種模式的一種
eg2:
Patternp=Pattern.compile("[a-z]\\s[a-z]");
Matcher m=p.matcher("b??? c");
if(m.matches())??? Sysout(1111);
else? Sysout(2222);? 輸出結(jié)果為1111;
一個匹配方法,一個返回String的字面值模式方法:
boolean matches(String
regex,CharSequence input);//input與regex匹
配返回true。
String quote(String s);//返回指定String的字面值。
eg3:boolean bool=Pattern.matches("[a-z] [a-z]",”b c”); //結(jié)果為true
Sysout(Pattern.quote(“a_#/tb”)); //輸出結(jié)果為“\Qa_# b”\E
[if !supportLists](3)???????[endif]6個普通方法
返回此模式的匹配器:Matcher?matcher(CharSequence input);
返回此模式的標(biāo)志:?? int flags();
返回此模式的regex:? String pattern();
兩個字符串切割方法:String[] split(CharSequence input);
??????? ???? String[]split(CharSequence input,int limit);
??????? ???? limit為返回字符串的個數(shù),如果等于0,返回所有???? ???? 拆分的字符串,如果大于拆分字符串的實際個數(shù),
??????? ???? 返回實際個數(shù)。
toString方法:??? ???? String toString();
??? ? eg4:
??????? Patternp=Pattern.compile("[,;\\s]");
??????? String str="wo,ai;nihaha";
??????? String[] strs=p.split(str);
??????? for(String s : strs){
??????????? Sysout(s);//輸出“wo” “ai” “ni” “haha”
??????? }
??????? strs=p.split(str,2)
??????? for(String s : strs){
??????????? Sysout(s);//輸出“wo” “ai;ni haha”
??????? }
??????? Strs=p.split(str,0)
??????? for(String s : strs){
??????????? Sysout(s);//輸出“wo” “ai” “ni” “haha”
??????? }
[if !supportLists]12 [endif]常用正則表達(dá)式
[if !supportLists](1)???????[endif]"^\d+$" //非負(fù)整數(shù)(正整數(shù) + 0)
[if !supportLists](2)???????[endif]"^[0-9]*[1-9][0-9]*$" //正整數(shù)
[if !supportLists](3)???????[endif]"^((-\d+)|(0+))$" //非正整數(shù)(負(fù)整數(shù) + 0)
[if !supportLists](4)???????[endif]"^-[0-9]*[1-9][0-9]*$" //負(fù)整數(shù)
[if !supportLists](5)???????[endif]"^-?\d+$" //整數(shù)
[if !supportLists](6)???????[endif]"^\d+(\.\d+)?$" //非負(fù)浮點(diǎn)數(shù)(正浮點(diǎn)數(shù) + 0)
[if !supportLists](7)???????[endif]"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮點(diǎn)數(shù)
[if !supportLists](8)???????[endif]"^((-\d+(\.\d+)?)|(0+(\.0+)?))$" //非正浮點(diǎn)數(shù)(負(fù)浮點(diǎn)數(shù) + 0)
[if !supportLists](9)???????[endif]"^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //負(fù)浮點(diǎn)數(shù)
[if !supportLists](10)??? [endif]"^(-?\d+)(\.\d+)?$" //浮點(diǎn)數(shù)
[if !supportLists](11)??? [endif]"^[A-Za-z]+$" //由26個英文字母組成的字符串
[if !supportLists](12)??? [endif]"^[A-Z]+$" //由26個英文字母的大寫組成的字符串
[if !supportLists](13)??? [endif]"^[a-z]+$" //由26個英文字母的小寫組成的字符串
[if !supportLists](14)??? [endif]"^[A-Za-z0-9]+$" //由數(shù)字和26個英文字母組成的字符串
[if !supportLists](15)??? [endif]"^\w+$" //由數(shù)字、26個英文字母或者下劃線組成的字符串
[if !supportLists](16)??? [endif]"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" //email地址
[if !supportLists](17)??? [endif]"^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$" //url
[if !supportLists](18)??? [endif]/^(d{2}|d{4})-((0([1-9]{1}))|(1[1|2]))-(([0-2]([1-9]{1}))|(3[0|1]))$/?? //? 年-月-日
[if !supportLists](19)??? [endif]/^((0([1-9]{1}))|(1[1|2]))/(([0-2]([1-9]{1}))|(3[0|1]))/(d{2}|d{4})$/?? //月/日/年
[if !supportLists](20)??? [endif]"^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$"?? //Emil
[if !supportLists](21)??? [endif]/^((\+?[0-9]{2,4}\-[0-9]{3,4}\-)|([0-9]{3,4}\-))?([0-9]{7,8})(\-[0-9]+)?$/???? //電話號碼
[if !supportLists](22)??? [endif]"^(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5])$"?? //IP地址
[if !supportLists](23)??? [endif]?
[if !supportLists](24)??? [endif]匹配中文字符的正則表達(dá)式:[\u4e00-\u9fa5]
[if !supportLists](25)??? [endif]匹配雙字節(jié)字符(包括漢字在內(nèi)):[^\x00-\xff]
[if !supportLists](26)??? [endif]匹配空行的正則表達(dá)式:\n[\s| ]*\r
[if !supportLists](27)??? [endif]匹配HTML標(biāo)記的正則表達(dá)式:/<(.*)>.*<\/\1>|<(.*)\/>/
[if !supportLists](28)??? [endif]匹配首尾空格的正則表達(dá)式:(^\s*)|(\s*$)
[if !supportLists](29)??? [endif]匹配Email地址的正則表達(dá)式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
[if !supportLists](30)??? [endif]匹配網(wǎng)址URL的正則表達(dá)式:^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$
[if !supportLists](31)??? [endif]匹配帳號是否合法(字母開頭,允許5-16字節(jié),允許字母數(shù)字下劃線):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
[if !supportLists](32)??? [endif]匹配國內(nèi)電話號碼:(\d{3}-|\d{4}-)?(\d{8}|\d{7})?
[if !supportLists](33)??? [endif]匹配騰訊QQ號:^[1-9]*[1-9][0-9]*$
[if !supportLists](34)??? [endif]元字符及其在正則表達(dá)式上下文中的行為:
[if !supportLists](35)??? [endif]\ 將下一個字符標(biāo)記為一個特殊字符、或一個原義字符、或一個后向引用、或一個八進(jìn)制轉(zhuǎn)義符。
[if !supportLists](36)??? [endif]^ 匹配輸入字符串的開始位置。如果設(shè)置了 RegExp 對象的Multiline 屬性,^ 也匹配 ’\n’ 或 ’\r’ 之后的位置。
[if !supportLists](37)??? [endif]$ 匹配輸入字符串的結(jié)束位置。如果設(shè)置了 RegExp 對象的Multiline 屬性,$ 也匹配 ’\n’ 或 ’\r’ 之前的位置。
[if !supportLists](38)??? [endif]* 匹配前面的子表達(dá)式零次或多次。
[if !supportLists](39)??? [endif]+ 匹配前面的子表達(dá)式一次或多次。+ 等價于 {1,}。
[if !supportLists](40)??? [endif]? 匹配前面的子表達(dá)式零次或一次。? 等價于 {0,1}。
[if !supportLists](41)??? [endif]{n} n 是一個非負(fù)整數(shù),匹配確定的n 次。
[if !supportLists](42)??? [endif]{n,} n 是一個非負(fù)整數(shù),至少匹配n 次。
[if !supportLists](43)??? [endif]{n,m} m 和 n 均為非負(fù)整數(shù),其中n <= m。最少匹配 n 次且最多匹配 m 次。在逗號和兩個數(shù)之間不能有空格。
[if !supportLists](44)??? [endif]? 當(dāng)該字符緊跟在任何一個其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面時,匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字符串,而默認(rèn)的貪婪模式則盡可能多的匹配所搜索的字符串。
[if !supportLists](45)??? [endif]. 匹配除 "\n" 之外的任何單個字符。要匹配包括 ’\n’ 在內(nèi)的任何字符,請使用象 ’[.\n]’ 的模式。
[if !supportLists](46)??? [endif](pattern) 匹配pattern 并獲取這一匹配。
[if !supportLists](47)??? [endif](?:pattern) 匹配pattern 但不獲取匹配結(jié)果,也就是說這是一個非獲取匹配,不進(jìn)行存儲供以后使用。
[if !supportLists](48)??? [endif](?=pattern) 正向預(yù)查,在任何匹配 pattern 的字符串開始處匹配查找字符串。這是一個非獲取匹配,也就是說,該匹配不需要獲取供以后使用。
[if !supportLists](49)??? [endif](?!pattern) 負(fù)向預(yù)查,與(?=pattern)作用相反
[if !supportLists](50)??? [endif]x|y 匹配 x 或 y。
[if !supportLists](51)??? [endif][xyz] 字符集合。
[if !supportLists](52)??? [endif][^xyz] 負(fù)值字符集合。
[if !supportLists](53)??? [endif][a-z] 字符范圍,匹配指定范圍內(nèi)的任意字符。
[if !supportLists](54)??? [endif][^a-z] 負(fù)值字符范圍,匹配任何不在指定范圍內(nèi)的任意字符。
[if !supportLists](55)??? [endif]\b 匹配一個單詞邊界,也就是指單詞和空格間的位置。
[if !supportLists](56)??? [endif]\B 匹配非單詞邊界。
[if !supportLists](57)??? [endif]\cx 匹配由x指明的控制字符。
[if !supportLists](58)??? [endif]\d 匹配一個數(shù)字字符。等價于 [0-9]。
[if !supportLists](59)??? [endif]\D 匹配一個非數(shù)字字符。等價于 [^0-9]。
[if !supportLists](60)??? [endif]\f 匹配一個換頁符。等價于 \x0c 和 \cL。
[if !supportLists](61)??? [endif]\n 匹配一個換行符。等價于 \x0a 和 \cJ。
[if !supportLists](62)??? [endif]\r 匹配一個回車符。等價于 \x0d 和 \cM。
[if !supportLists](63)??? [endif]\s 匹配任何空白字符,包括空格、制表符、換頁符等等。等價于[ \f\n\r\t\v]。
[if !supportLists](64)??? [endif]\S 匹配任何非空白字符。等價于 [^ \f\n\r\t\v]。
[if !supportLists](65)??? [endif]\t 匹配一個制表符。等價于 \x09 和 \cI。
[if !supportLists](66)??? [endif]\v 匹配一個垂直制表符。等價于 \x0b 和 \cK。
[if !supportLists](67)??? [endif]\w 匹配包括下劃線的任何單詞字符。等價于’[A-Za-z0-9_]’。
[if !supportLists](68)??? [endif]\W 匹配任何非單詞字符。等價于 ’[^A-Za-z0-9_]’。
[if !supportLists](69)??? [endif]\xn 匹配 n,其中 n 為十六進(jìn)制轉(zhuǎn)義值。十六進(jìn)制轉(zhuǎn)義值必須為確定的兩個數(shù)字長。
[if !supportLists](70)??? [endif]\num 匹配 num,其中num是一個正整數(shù)。對所獲取的匹配的引用。
[if !supportLists](71)??? [endif]\n 標(biāo)識一個八進(jìn)制轉(zhuǎn)義值或一個后向引用。如果 \n 之前至少 n 個獲取的子表達(dá)式,則 n 為后向引用。否則,如果 n 為八進(jìn)制數(shù)字 (0-7),則 n 為一個八進(jìn)制轉(zhuǎn)義值。
[if !supportLists](72)??? [endif]\nm 標(biāo)識一個八進(jìn)制轉(zhuǎn)義值或一個后向引用。如果 \nm 之前至少有is preceded by at least nm 個獲取得子表達(dá)式,則 nm 為后向引用。如果 \nm 之前至少有 n 個獲取,則 n 為一個后跟文字 m 的后向引用。如果前面的條件都不滿足,若 n 和 m 均為八進(jìn)制數(shù)字 (0-7),則 \nm 將匹配八進(jìn)制轉(zhuǎn)義值 nm。
[if !supportLists](73)??? [endif]\nml 如果 n 為八進(jìn)制數(shù)字 (0-3),且 m 和 l 均為八進(jìn)制數(shù)字 (0-7),則匹配八進(jìn)制轉(zhuǎn)義值 nml。
[if !supportLists](74)??? [endif]\un 匹配 n,其中 n 是一個用四個十六進(jìn)制數(shù)字表示的Unicode字符。
[if !supportLists](75)??? [endif]匹配中文字符的正則表達(dá)式:[u4e00-u9fa5]
[if !supportLists](76)??? [endif]匹配雙字節(jié)字符(包括漢字在內(nèi)):[^x00-xff]
[if !supportLists](77)??? [endif]匹配空行的正則表達(dá)式:n[s| ]*r
[if !supportLists](78)??? [endif]匹配HTML標(biāo)記的正則表達(dá)式:/<(.*)>.*|<(.*)/>/
[if !supportLists](79)??? [endif]匹配首尾空格的正則表達(dá)式:(^s*)|(s*$)
[if !supportLists](80)??? [endif]匹配Email地址的正則表達(dá)式:w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
[if !supportLists](81)??? [endif]匹配網(wǎng)址URL的正則表達(dá)式:http://([w-]+.)+[w-]+(/[w-./?%&=]*)?
[if !supportLists](82)??? [endif]利用正則表達(dá)式限制網(wǎng)頁表單里的文本框輸入內(nèi)容:
[if !supportLists](83)??? [endif]用正則表達(dá)式限制只能輸入中文:onkeyup="value=value.replace(/[^u4E00-u9FA5]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^u4E00-u9FA5]/g,''))"
[if !supportLists](84)??? [endif]用正則表達(dá)式限制只能輸入全角字符:onkeyup="value=value.replace(/[^uFF00-uFFFF]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^uFF00-uFFFF]/g,''))"
[if !supportLists](85)??? [endif]用正則表達(dá)式限制只能輸入數(shù)字:onkeyup="value=value.replace(/[^d]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))"
[if !supportLists](86)??? [endif]用正則表達(dá)式限制只能輸入數(shù)字和英文:onkeyup="value=value.replace(/[W]/g,'')"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))"
[if !supportLists](87)??? [endif]?
[if !supportLists](88)??? [endif]?
[if !supportLists](89)??? [endif]整理:
[if !supportLists](90)??? [endif]?
[if !supportLists](91)??? [endif]匹配中文字符的正則表達(dá)式:[\u4e00-\u9fa5]
[if !supportLists](92)??? [endif]匹配雙字節(jié)字符(包括漢字在內(nèi)):[^\x00-\xff]
[if !supportLists](93)??? [endif]匹配空行的正則表達(dá)式:\n[\s| ]*\r
[if !supportLists](94)??? [endif]匹配HTML標(biāo)記的正則表達(dá)式:/<(.*)>.*<\/\1>|<(.*)\/>/
[if !supportLists](95)??? [endif]匹配首尾空格的正則表達(dá)式:(^\s*)|(\s*$)
[if !supportLists](96)??? [endif]匹配IP地址的正則表達(dá)式:/(\d+)\.(\d+)\.(\d+)\.(\d+)/g//
[if !supportLists](97)??? [endif]匹配Email地址的正則表達(dá)式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
[if !supportLists](98)??? [endif]匹配網(wǎng)址URL的正則表達(dá)式:http://(/[\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?
[if !supportLists](99)??? [endif]sql語句:^(select|drop|delete|create|update|insert).*$
[if !supportLists](100)????????[endif]1、非負(fù)整數(shù):^\d+$
[if !supportLists](101)????????[endif]2、正整數(shù):^[0-9]*[1-9][0-9]*$
[if !supportLists](102)????????[endif]3、非正整數(shù):^((-\d+)|(0+))$
[if !supportLists](103)????????[endif]4、負(fù)整數(shù):^-[0-9]*[1-9][0-9]*$
[if !supportLists](104)????????[endif]?
[if !supportLists](105)????????[endif]5、整數(shù):^-?\d+$
[if !supportLists](106)????????[endif]?
[if !supportLists](107)????????[endif]6、非負(fù)浮點(diǎn)數(shù):^\d+(\.\d+)?$
[if !supportLists](108)????????[endif]?
[if !supportLists](109)????????[endif]7、正浮點(diǎn)數(shù):^((0-9)+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$
[if !supportLists](110)????????[endif]?
[if !supportLists](111)????????[endif]8、非正浮點(diǎn)數(shù):^((-\d+\.\d+)?)|(0+(\.0+)?))$
[if !supportLists](112)????????[endif]?
[if !supportLists](113)????????[endif]9、負(fù)浮點(diǎn)數(shù):^(-((正浮點(diǎn)數(shù)正則式)))$
[if !supportLists](114)????????[endif]?
[if !supportLists](115)????????[endif]10、英文字符串:^[A-Za-z]+$
[if !supportLists](116)????????[endif]?
[if !supportLists](117)????????[endif]11、英文大寫串:^[A-Z]+$
[if !supportLists](118)????????[endif]?
[if !supportLists](119)????????[endif]12、英文小寫串:^[a-z]+$
[if !supportLists](120)????????[endif]?
[if !supportLists](121)????????[endif]13、英文字符數(shù)字串:^[A-Za-z0-9]+$
[if !supportLists](122)????????[endif]?
[if !supportLists](123)????????[endif]14、英數(shù)字加下劃線串:^\w+$
[if !supportLists](124)????????[endif]?
[if !supportLists](125)????????[endif]15、E-mail地址:^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$
[if !supportLists](126)????????[endif]?
[if !supportLists](127)????????[endif]16、URL:^[a-zA-Z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\s*)?$
[if !supportLists](128)????????[endif]或:^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$
[if !supportLists](129)????????[endif]?
[if !supportLists](130)????????[endif]17、郵政編碼:^[1-9]\d{5}$
[if !supportLists](131)????????[endif]?
[if !supportLists](132)????????[endif]18、中文:^[\u0391-\uFFE5]+$
[if !supportLists](133)????????[endif]?
[if !supportLists](134)????????[endif]19、電話號碼:^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$
[if !supportLists](135)????????[endif]?
[if !supportLists](136)????????[endif]20、手機(jī)號碼:^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$
[if !supportLists](137)????????[endif]?
[if !supportLists](138)????????[endif]21、雙字節(jié)字符(包括漢字在內(nèi)):^\x00-\xff
[if !supportLists](139)????????[endif]?
[if !supportLists](140)????????[endif]22、匹配首尾空格:(^\s*)|(\s*$)(像vbscript那樣的trim函數(shù))
[if !supportLists](141)????????[endif]?
[if !supportLists](142)????????[endif]23、匹配HTML標(biāo)記:<(.*)>.*<\/\1>|<(.*) \/>
[if !supportLists](143)????????[endif]?
[if !supportLists](144)????????[endif]24、匹配空行:\n[\s| ]*\r
[if !supportLists](145)????????[endif]?
[if !supportLists](146)????????[endif]25、提取信息中的網(wǎng)絡(luò)鏈接:(h|H)(r|R)(e|E)(f|F) *=*('|")?(\w|\\|\/|\.)+('|"| *|>)?
[if !supportLists](147)????????[endif]?
[if !supportLists](148)????????[endif]26、提取信息中的郵件地址:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
[if !supportLists](149)????????[endif]?
[if !supportLists](150)????????[endif]27、提取信息中的圖片鏈接:(s|S)(r|R)(c|C) *=*('|")?(\w|\\|\/|\.)+('|"| *|>)?
[if !supportLists](151)????????[endif]?
[if !supportLists](152)????????[endif]28、提取信息中的IP地址:(\d+)\.(\d+)\.(\d+)\.(\d+)
[if !supportLists](153)????????[endif]?
[if !supportLists](154)????????[endif]29、提取信息中的中國手機(jī)號碼:(86)*0*13\d{9}
[if !supportLists](155)????????[endif]?
[if !supportLists](156)????????[endif]30、提取信息中的中國固定電話號碼:(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}
[if !supportLists](157)????????[endif]?
[if !supportLists](158)????????[endif]31、提取信息中的中國電話號碼(包括移動和固定電話):(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}
[if !supportLists](159)????????[endif]?
[if !supportLists](160)????????[endif]32、提取信息中的中國郵政編碼:[1-9]{1}(\d+){5}
[if !supportLists](161)????????[endif]?
[if !supportLists](162)????????[endif]33、提取信息中的浮點(diǎn)數(shù)(即小數(shù)):(-?\d*)\.?\d+
[if !supportLists](163)????????[endif]?
[if !supportLists](164)????????[endif]34、提取信息中的任何數(shù)字 :(-?\d*)(\.\d+)?
[if !supportLists](165)????????[endif]?
[if !supportLists](166)????????[endif]35、IP:(\d+)\.(\d+)\.(\d+)\.(\d+)
[if !supportLists](167)????????[endif]?
[if !supportLists](168)????????[endif]36、電話區(qū)號:/^0\d{2,3}$/
[if !supportLists](169)????????[endif]?
[if !supportLists](170)????????[endif]37、騰訊QQ號:^[1-9]*[1-9][0-9]*$
[if !supportLists](171)????????[endif]?
[if !supportLists](172)????????[endif]38、帳號(字母開頭,允許5-16字節(jié),允許字母數(shù)字下劃線):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
[if !supportLists](173)????????[endif]?
[if !supportLists](174)????????[endif]39、中文、英文、數(shù)字及下劃線:^[\u4e00-\u9fa5_a-zA-Z0-9]+$