/g. 複数の結果を返したくないようです
次のコードがあります
<div id="test">
<p> <!--{Byond:cta|localAction:contact|Contact Us}--><\/p>
<p> <\/p> <p> <sub><strong>Important Information:<\/strong> Offer
only available for new home loans. *Comparison Rate is calculated on a loan amount of
$150,000 over a term of 25 years. **Minimum redraw of $500. ^Limits apply for fixed rate
home loans.<\/sub><\/p> <!--{Byond:cta|localAction:product:45|Product}-->
</div>
byond ローカルアクション amd の各インスタンスを取得してから、文字列を分割しようとしています
私は使っている
var introduction = $("#test").html();
var initExpr = /<!--{Byond\:cta\|localAction[^}]+}-->/gm;
var initResult = initExpr.exec(introduction);
// this result is always 1... WHY?
var length = initResult.length;
//based on the length split the results up
for (var i = 0; i < length; i++) {
var expr = /(?:<!--{Byond\:cta\|)(.*)\|(.*)(?:}-->)/i;
var result = expr.exec(introduction);
console.log(result[0], "String");
console.log(result[1], "Local Action");
console.log(result[2], "Button Name");
}
最初の結果の長さは1しか得られません..2になるはずです..そして、それを使用して個々の結果を分割する必要があります
誰でも助けてくれますか