秒速赛车打不开

match()與exec()區別

2018-9-12 09:38|作者: admin|查看: 8176|評論: 0|來自: 螞蟻部落

GUANYULIANGGEFANGFADEJIBENYONGFAKEYICANYUEYIXIALIANGPIANWENZHANG:

(1).正則表達式 exec()方法一章節。

(2).正則表達式match()方法一章節。

秒速赛车打不开ZHIYAOYUEDUSHANGSHULIANGPIANWENZHANG,BINGZHANGWOGEZIYONGFA,ZIRANJIUHENQINGCHUTAMENZHIJIANDEQUBIE。

WEILEBIANYUXUEXI,BENWENZAIJIANGLIANGGEFANGFADEQUBIEJINXINGYIXIAZONGJIE。

一.所屬對象的不同:

ZHEGEQUBIEZUIWEIJIANDANMINGXIAN。

matchFANGFASHUYUZIFUCHUANDUIXIANG,execFANGFASHUYUZHENGZEBIAODASHIDUIXIANG。

DAIMASHILIRUXIA:

[JavaScript] 純文本查看 復制代碼运行代码
let str="antzone"; let reg=/n/;console.log(reg.exec(str));

execFANGFADEDIAOYONGDUIXIANGSHIZHENGZEBIAODASHIDUIXIANG,FANGFADECANSHUSHIZIFUCHUAN。

[JavaScript] 純文本查看 復制代碼运行代码
let str="本站url地址是glbcf.cn"; let reg=/why/;console.log(str.match(reg));

秒速赛车打不开matchFANGFAYOUZIFUCHUANDUIXIANGDIAOYONG,FANGFADECANSHUSHIZHENGZEBIAODASHI。

二.方法返回結果的不同:

(1).非全局匹配:

DANGCAIYONGFEIQUANJUPIPEIDESHIHOU,LIANGGEFANGFADEFANHUIZHIWANQUANYIYANG。

DAIMASHILIRUXIA:

[JavaScript] 純文本查看 復制代碼运行代码
let str="antzoane"; let reg=/a(n)/;console.log(str.match(reg));console.log(reg.exec(str));

DAIMAYUNXINGXIAOGUOJIETURUXIA:

a:3:{s:3:\"pic\";s:43:\"portal/201809/12/094223yvochn7ddoe6ctfv.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

秒速赛车打不开HENMINGXIAN,LIANGGEFANGFADEFANHUIZHISHIYIMOYIYANGDE。

(2).全局匹配:

DANGWEIQUANJUPIPEIDESHIHOU,FANHUIJIEGUOCHUXIANHENDABUTONG。

秒速赛车打不开matchFANGFAFANHUIYIGECUNFANGSUOYOUPIPEINEIRONGDESHUZU(WUSHIZIBIAODASHIDEPIPEI)。

exexFANGFAFANHUISHUZUBUHUICUNCHUSUOYOUDEPIPEI,JINCUNCHUDIYIGEPIPEIDAODENEIRONG(CUNCHUZAISHUZIDIYIGEYUANSU),DIERGEYUANSUCUNCHUDIYIGEZIBIAODASHIPIPEIDAODENEIRONG,DISANGEYUANSUCUNCHUDIERGEZIBIAODASHIPIPEIDAODENEIRONG,YICILEITUI。

[JavaScript] 純文本查看 復制代碼运行代码
let str="antzoane"; let reg=/a(n)/g;console.log(str.match(reg));console.log(reg.exec(str));

DAIMAYUNXINGXIAOGUOJIETURUXIA:

a:3:{s:3:\"pic\";s:43:\"portal/201809/12/094339kmsm5uchkmkdh5dt.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

YUNXINGXIAOGUOJIETUYINZHENGLEQIANMIANDELILUNCHANSHU。QUANJUPIPEIXIA,execFANGFAHUANKEYIYUlastIndexSHUXINGPEIHESHIYONG。

lastIndexSHUXINGKEYIFANHUIHUOZHESHEZHIZHENGZEBIAODASHIJIANGYAOKAISHIDEPIPEIDEQISHIWEIZHI。

DUImatchFANGFAERYAN,lastIndexSHUXINGZHISHIZHONGWEI0。

[JavaScript] 純文本查看 復制代碼运行代码
let str="ant8zone"; let reg=/\d/g;console.log(reg.exec(str));console.log(reg.lastIndex);

DAIMAYUNXINGXIAOGUOJIETURUXIA:

a:3:{s:3:\"pic\";s:43:\"portal/201809/12/094414t3jknaisiwuis9mu.png\";s:5:\"thumb\";s:0:\"\";s:6:\"remote\";N;}

CHUSHIZHUANGTAIlastIndexSHUXINGZHIWEI0,ZHENGZEBIAODASHIPIPEIDAOSHUZI8,ZAIZIFUCHUANZHONGDEWEIZHIWEI3。

NEIMEXIAYICIJIUSHICONGZIFU"z"CHUKAISHIPIPEI,"z"DEWEIZHISHI4。

秒速赛车打不开DUIYUmatchFANGFAERYAN,lastIndexZHISHIZHONGWEI0,JIBENMEISHASHIZHIYINGYONGYIYI。

1

鮮花

握手

雷人

路過

雞蛋

剛表態過的朋友 (1 人)

最新評論

返回頂部