??????Ƽ?????Iphone??????????Ϸ?羺lolcosplay??????ҫ????allcnewsBLOGNEWSBLOGASKBLOGBLOGZSKȫ???????ʴ??ʴ??????ʴ?it?ʴ?????????????????????????/?????ֻ?/?????ʼDZ???????????????ϵͳ????Ӳ????̿???360??Ʒ??Դ????????֪ʶ?ĵ?????ITȫ??ȫ??????ȫ??????????ţ??ȫ???????̳???????ҳ????cms?̳?ƽ?????ý?嶯??????ϵͳ??վ??Ӫ???簲ȫ???????̳????ݿ⹤?????簲ȫ??????ѧvbscript???????ʽjavascript??????????»??̸????̸̳?????Ϸ????allitnewsJava????????ҽ????Ϣ????ȫ??ҵվ???????Ƽ???̸????????ר????ҵ??̬???ʴ?Ͷ??ҵѧԺ / ??Ʒ??????ҵ??˾?????̸Ӫ?????????ݿ???????ϵͳ???⻯?Ƽ???Ƕ??ʽ?ƶ???????ҵ??ҵ1????????all?????????ֻ???????????Ϸ?????˶?????Ӱ?????а????Ļ??????????????????ѧҽ?ƽ??????ڹ???????罻??????????????????????Ӳ????̿???360??ز?Ʒ?ֻ?ƽ?????????Ӳ?Ʒ??Ӱ????360Ӳ??ͨѶ?????豸????ʱ?????ʶ??????????װ??????????????ͨ??????????ҵ?Ҿ?װ????ʳ?????????????Ϸ??ҳ??Ϸ??????Ϸ??????????Ϸ?ֻ???ϷС??Ϸ?ƻ???Ϸ?ͻ?????Ϸ??????Ϸ??????Ϸ?????????????????????˶??????˶??????????˶??˶???ƷӰ????????????????????Ӱ?????ղ???????Ĭ??Ц?????????????????Ʊ????ռ???黭?????赸С˵ͼ??????????СƷ????Ϸ??Ϸ???ֹ???Ʒ??ʷ????ʱ????????ҵְ?????¹??????շ??????ɷ????ڽ??????????Ȼ?ֺ?360άȨ?????????ѧ??ѧ????????????ʸ???????Ա??ѧ??????ͥ????ѧϰ????????????????????ѧũҵ??ѧ??ѧ????֪ʶ????????????????ڿ??????????????Ƥ??????ٿ??п???????ҽҩƷ??Ⱦ??????????ҽԺ????????????ҵͶ????ҵ????????˰????????Ʊ????????????ծȯ????ó?????????????񾭼???????????ͥ?????????Ϻ???????????????????????ӱ????ɹ?ɽ???????????????ຣ?½??????Ĵ?????????????????????ɽ???????㽭?????????????㶫???????????????̨?????????

沙巴盘皇冠盘波音平台bbin线上博彩

??Դ???ű?֮??  ???α༭:С??  

?????飨capturing group???????????ʽ??Ƚϳ??ã?Ҳ?DZȽ???Ҫ?ĸ???Ҹ??˾????????ⲿ?ֵ?֪ʶ?Ƿdz???Ҫ?ġ?

??ƪ???????ݲ???????룬???Ǿ??????????׶???ȫ?档??????????????Ҫ??Χ??????7???㣺

1: () ??????
2: (?:) non capturing group
3: (?=) positive lookahead
4: (?!) negative lookahead
5: (?<=) positive lookbehind
6: (?<!) negative lookbehind
7: (?=), (?!), (?<=), (?<!)?IJ???

1: () ??????

/go+/

???ϵ????????ʽ??ʾһ????ĸg???????һ?????߶????ĸo,????ƥ??go????goooo???????????????+??ֻ?????õ???ĸo?ϣ????????õ?go???????????ô???أ??취???Ǹ?go?????ţ?

/(go)+/

Ϊ??ȫ??ƥ???Լ??????Ǵ?Сд?????ǽ???????????ǵ????????ig,??????flag??

let reg = /(go)+/ig;
'go is g gogo'.match(reg); //["go", "gogo"]

???????????????(go)???γ???һ???????飨capturing group????????????һ??ʹ?ò????????????????????????⣺

let reg = /(\d{2}).(\d{2}).(\d{4})/;
let originString = '10.25.2017';
reg.test(originString); //true
RegExp.$1; //10
RegExp.$2; //25
RegExp.$2; //2017

???????????????????????????ţ??γ????????????飬???????ʽ????javaScript????????ǵ?RegExp???Ỻ?沶??????ƥ??Ĵ?????$n??ʾ??n?ʹ?????ڼ????????顣

??????????????һ?????󣺰???ʾ??ʽΪ 10.25.2017 ??ʱ???Ϊ 2017-10-25 ??ʽ??

????֪??String??replace()?????????????????ʽһ??ʹ?á???replace()????????ǿ???ֱ??ʹ?ò?????Ľ????

let reg = /(\d{2}).(\d{2}).(\d{4})/;
let originString = '10.25.2017';
let newString = originString.replace(reg, '$3-$1-$2');
console.log(newString);//"2017-10-25"

2: (?:) non capturing group ?Dz????ͷ???

?е?ʱ?????ǿ???ֻ??ƥ????飬???Dz????뻺?棨???벶??ƥ?䵽?Ľ?????Ϳ????????ǵķ???ģʽǰ??????:???????????ʱ??????ӣ????Dz??벶???һ??????Ľ?????Ϳ?????ô????

let reg = /(?:\d{2}).(\d{2}).(\d{4})/;
let originString = '10.25.2017';
reg.test(originString); //true
RegExp.$1; //25
RegExp.$2; //2017
originString.match(reg);// ["10.25.2017", "25", "2017", index: 0, input: "10.25.2017", groups: undefined]

??????????ӿ??Կ????????ǵ????????ʽ??Ȼ??ƥ??ģ?test()?Ľ????ȻΪtrue????????RegExp.$1????????10??????25????Ϊ?????ڵ?һ????????????:??10?Ͳ??ᱻ????match()??ִ?н??Ҳ?????:??Ӱ?죺match()?Ľ???ﲻ???С?10'??

3: (?=) positive lookahead ????ǰհ?Ͳ???

??һ?????ӣ?1 apple costs 10?. ??????Ҫƥ??ǰ??ļ۸???????һ?????֣???????ע?ⲻ??ƥ?䵽???ӿ?ͷ??????1????????????Ϳ????õ?????ǰհ?Ͳ???

let reg = /\d+(?=?)/g;
let reg1 = /\d+/g;
let str = '1 apple costs 10?';
str.match(reg); //["10"]
str.match(reg1); //["1", "10"]

?????????????reg1??ֻ??Ҫƥ?????֣????????ֺ????ʲô??û??Ҫ??????????ƥ?䵽1??10??????regʹ????ǰհ??ƥ?䣬??ֻ??ƥ?䵽10??
???????Ѿ??ܴ?????ĶԱ????˽⵽ʲô??????ǰհ?Ͳ????ˣ???˼??:

/x(?=y)/ ƥ??x, ???DZ?????x?ġ????桿???ǡ?y???????

4: (?!) negative lookahead ????ǰհ?Ͳ???

?????????˽???ʲô??????ǰհ??ƥ?䣬????????˼Ҳ?ܲ³???????ǰհ?Ͳ??????:

/x(?!y)/ ƥ??x, ???DZ?????x?ġ????桿?????ǡ?y???????

????????????ӣ?????Ҫƥ??????1??????Ҫ?ǰ???2???Ϳ????õ??!??

let reg = /\d+(?!?)/g;
let str = '1 apple costs 2?';
str.match(reg); ['1']

5: (?<=) positive lookbehind ???????Ͳ???

????ͺ?ǰհ???????෴????˼???ǣ?

/(?<=y)x/ ƥ??x, ????ֻ?ڡ?ǰ?桿???С?y???????

????һ?????ӣ?

let str = "1 turkey costs $2";
console.log( str.match(/(?<=\$)\d+/g) ); //["2"]

?????Ҫ????ǰ????$?????֣?????????ƥ?䵽??????2????û??1.

6: (?<!) negative lookbehind ???????Ͳ???

??????????????෴????ô???????Ͳ?????ǣ?

/(?<=y)x/ ƥ??x, ????ֻ?ڡ?ǰ?桿??û?С?y???????

????һ?????ӣ?

let str = "1 turkey costs $2";
console.log( str.match(/(?<!\$)\d+/g) ); //['1']

7: (?=), (?!), (?<=), (?<!)?IJ???

Ĭ????????????ǰհ???4?ֶ???Ĭ?ϲ?ƥ?䲶????????????ݵģ?Ҳ???Dz?ƥ??????????????ġ????????ǵ?????ǰհ/d+(?=?)/g??ֻ??ƥ?䵽???֣???????ƥ?䵽????????????ҪҲƥ?䵽???ô???أ??𰸾??Ǹ??Ҳ????һ?????ţ?

let str = "1 turkey costs 2?";
let reg = /\d+(?=(?))/; 
str.match(reg); //["2", "?", index: 15, input: "1 turkey costs 2?", groups: undefined]

??????ƥ?䵽??????2????????Ā??

????????????????ͣ?

let str = "1 turkey costs $2";
let reg = /(?<=(\$|£))\d+/;
console.log( str.match(reg) ); //["2", "$", index: 16, input: "1 turkey costs $2", groups: undefined]

??Ҫ?ر?ע?⵽??һ???ǣ????ں???ͣ???Ȼ??????ƥ?????ǰ?棬????ƥ??????Ľ??˳????Ȼ????????ƥ????ĺ??档????????match()?????Ľ????2??$??ǰ?档

?ܽ?

??????????С?????ҽ??ܵ????????ʽ ??????,ϣ???Դ?????????????????????κ?????????????ԣ?С??ἰʱ?ظ???ҵġ??ڴ?Ҳ?dz???л??ҶԽű?֮????վ??֧?֣?
???????ñ??Ķ????а???????ӭת?أ?????ע????????лл??

?????ܸ???Ȥ??????:


  • ??????أ?
  • php???????ʽ֮????????Dz?????
  • php֮???????ʽ????????Dz????飨??⣩
  • ???????ʽ֮??????/?Dz????????
  • ???????????ʽ?ж?һ?????????ַ??Ƿ??ǻ???
  • javascript֮???????ʽ????֪ʶС??
  • ƥ??5??10λ???ظ????ֵ????????ʽ
  • js???????ʽ ƥ???????ض??ַ????????ʾ??
  • asp.net?????????????ʽ?ж?һ???ַ????Ƿ?Ϊ???ֵĴ???
  • js???????match()???滻replace()?÷?ʵ??
  • linux???????ʽ??????⼰bre??ere????ͬ??
  • ???? ?????飨capture group??
  • ?Ƚϲ?????c#?еij??õ????????ʽ
  • ???????ʽ?ж?????2λС????ʵ?ִ???
  • ???????? - ???????? - ??ϵ???? - ?????ϵ - ???????? - ???????? - Ƶ??????
    Copyright © 2017 www.pradaoutletonline.net All Rights Reserved