1. Verify the string consisting of 1 to 20 digits: var regular =/^ [0-9] {} $ /;
2.G goes down. I is case insensitive.
VaR DATA = "123123 ";
VaR recat =/123/GI; alert (recat. Test (data); // true
Test: var recat =/CAT/g; Every time you get one, it is automatically transferred to the next one! If you enter two "cat", the value is null when you click the third time.
3,
VaR DATA = "ah-mousemouse ";
VaR redata =/(Mouse) {2}/GI;
VaR arrdata = data. Match (recat );
For (VAR I = 0; I <arrdata. length; I ++)
{
Alert (arrdata [I]);
}
< Script Language = " Javascript " >
<! --
/* Groups with complex Regular Expressions
? Zero or once
* Zero or multiple times
+ At least once or multiple times
*/
VaR Data = " Bb ba da bad dad AA " ;
VaR Recat = / ([Bd] ad ?) / GI; // Match ba da bad dad
VaR Arrdata = Data. Match (recat );
For ( VaR I = 0 ; I < Arrdata. length; I ++ )
{
Alert (arrdata [I]);
}
// At the same time, you don't mind placing groups in the middle of the group.
// VaR Re =/(MOM (and Dad )?) /; Match Mom or Mon and daa
// -->
< / SCRIPT>
Reference connection:
Javascript Regular Expression
New Javascript Regular Expression
Alicloud's personal space
Getting started with regular expressions in 30 minutes
Http://msdn.microsoft.com/zh-cn/library/ae5bf541 (vs.80). aspx