javascript - Capturing a pattern multiple times -
I want to parse all the links inside the HTML string, as it looks like the following:
& lt; A href = "Javascript: makepop ('match_stats_popup.php? MatchID = 185934701')" & gt; Match stats & lt; / A & gt; & Lt; A href = "javascript: makepop ('http://www.atpworldtour.com/Share/Match-Facts-Pop-Up.aspx?t=416&y=2014&r=5&p=p643')" & Gt; Match stats & lt; / A & gt;
There is an array of expected output links:
['match_stats_popup.php? MatchID = 185934701, 'http: //www.atpworldtourcom / share / match-facts-pop-up.aspx? T = 416 & y = 2014 & amp; R = 5 & amp; I have created this function but it does ": function parseMatchStatsLinks (html) {var regex = / href =" Javascript: makePopup \ ('(. *)' \) "/ G; var match = []; var link = [], while (match = regex.exec (html)) {links.push (match [1]) ;} Return link;}
To make it non-greedy, ?
was to add:
href = "javascript: makepup \ ('(. *?)' \" "
Comments
Post a Comment