The regular exec method returns what value groups is used to store in the array?


var str = "ac123abc456abc";
var result = reg.exec (str);
console.log (result);
/ / = > result: ["123", index: 2, input: "ac123abc456abc", groups: undefined]
/ / = > what is the function of groups?


groups is a new field , which is used to store information about named capture groups:

 

change reg in your example to / (\ d +) / the part enclosed in parentheses is called "capture", and the corresponding English is group. The group in the result in
exec is used to enumerate the capture of "names and names".

change reg to / (? < test >\ d+) / , where ? < test > means that the captured "name" is test,. If you execute it, you will see that there is an extra attribute named test in result.groups, where the corresponding value is \ d + matching text.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b325c8-2b585.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b325c8-2b585.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?