Complex mode:
Group
var redogdog=/dogdog/g;---------------var redogdog=/(dog) {2}/g;
* Citation: (note with parentheses and without parentheses)
var smatch= "#123456789";
var renum=/(# (\d+))/;
Renum.test (Smatch);
Alert (regexp.$1+ "" +regexp.$2);
var schange= "1234 5678";
var rematch=/(\d{4}) (\d{4})/; //Pay attention to spaces in the middle
var newstr=schange.replace (rematch, "$ $"); //not "regexp.$2 regexp.$1"
Alert (regexp.$1+ "" +regexp.$2);//Note this line is output: 1234 5678, there is a sense of the above to cover the regular (deep mechanism is unclear)
Alert (schange+ "" +newstr);
* Candidate: Pipe break |
var s1= "Red";
var s2= "Blue";
var res1s2=/(red|blue)/;
Alert (Res1s2.test (S1));
Alert (res1s2.test (S2));
* Non-capturing grouping
var stomatch= "#123456789";
var renumbers=/# (?: \ d+)/;
Renumbers.test (Stomatch);
alert (regexp.$1);//Output "" Because the group is non-capturing
* Prospective
var stomatch1= "bedroom";
var stomatch2= "bedding";
var rebed=/(bed (? =room))/;
Alert (Rebed.test (STOMATCH1));
alert (regexp.$1);
Alert (Rebed.test (STOMATCH2));
Result: True bed false
* Boundary: ^ Line beginning $ line end \b Word boundary \b non-word boundary
var stomatch= "Important Word is the last one.";
var relastword=/(\w+). $/;
Relastword.test (Stomatch);
alert (regexp.$1);
* Multiline Mode (The following example feels a problem, minus G, the result is not what I think)
var stomatch= "First Second\nthird fourth\nfifth sixth";
var relastwordonline=/(\w+) $/g;
var arrwords=stomatch.match (relastwordonline);
alert (arrWords);
A summary of the regular complex patterns in JS elevation