関数内の入力またはスポット (常にラインに沿ったもの):
ワシントン、T. ラッシュで MT0 まで 3 ヤード
to the MT0
テキスト " "を取得したい
homeacrynm
「MT」は、varまたはawayacrynm
関数呼び出しの前に初期化するものと一致します。これが私がこれまでに試したことです:
getEndSpotEugene: function(spot)
{
var regex = new RegExp("to the +("+homeacrynm+"|"+awayacrynm+")?([0-9]{1,2})","g");
var matches = spot.match(regex);
if (matches)
{
pos = matches[matches.length-1]
matches = pos.match(/to the ([A-Z]+)?([0-9]{1,2})/);
if (!matches[1])
{
matches=[pos,"V",50];
}
}
else
{
return -1;
}
var acr = matches[1];
var yard = matches[2];
if (acr == homeacrynm)
return "H"+yard;
else
return "V"+yard;
},
例 (1 つの単純なケース):
homeacrynm = "MT"
var giveMe = getEndSpotEugene("Washington, T. rush for 3 yards to the MT11")
giveMe
H11 である必要がありますが、何らかの理由でそうではありません。
どこが間違っているのかもよくわかりません。私が見逃しているものはありますか?ありがとうございました!