The example in this article describes the method of JavaScript string loop matching. Share to everyone for your reference. Specifically as follows:
Using the Exec and String.match methods, the global match G identity must be turned on for exec to get all matches
Need to extract this data <td>2012-12-17</td><td>11:02, 12:25, 13:22, 15:06, 15:12, 19:22, 23:47</td> var RawData = ' <table><th align= "left" scope= "col" > Date </th><th align= "left" scope= "col" > Check-in time </th></tr><tr class= "Gridviewrowstyle" style= "height:20px;" > ' + ' <td>2012-12-03</td><td>10:16, 13:22, 20:05</td></tr><tr class= "GridViewRo Wstyle "style=" height:20px; "
> ' + ' <td>2012-12-04</td><td>11:16, 14:22, 21:05</td></tr><table> '; Method one var regexp =/<td> (\d{4}-\d{2}-\d{2}) <\/td><td> (. *?)
<\/td>/g;
Plus the G logo will match globally, otherwise only one var Matchedarray = regexp.exec (rawdata) is matched;
while (Matchedarray!= null) {Console.dir (Matchedarray);
Matchedarray = Regexp.exec (rawdata); }//Method two var regexp =/<td> (\d{4}-\d{2}-\d{2}) <\/td><td> (. *?)
<\/td>/g;
Plus the G logo will globally match var Matchedarray = Rawdata.match (regexp); Console.dir (Matchedarray); Method three var regexp =/<td> (\d{4}-\d{2}-\d{2}) <\/td><td> (. *?)
<\/td>/;
Do not add G to identify var Matchedarray = Rawdata.match (regexp);
Console.dir (Matchedarray);
Console.log (Matchedarray.index);
while (Matchedarray!= null) {rawdata = Rawdata.substr (Matchedarray.index + matchedarray[0].length);
Matchedarray = Rawdata.match (regexp);
} console.dir (Matchedarray);
The
wants this article to help you with your JavaScript programming.