1
現在のところ、正規表現を使用してSet 1 Total Games Over/Under 9.5
というセット文字列を並べ替えて、Under/Over N Giochi Set 1
と読み替えるようにしています。現在、私は、データ出力に次の使用:正規表現を使用した後のJavaScriptの非構造化代入
let marketLabel = 'Set 1 Total Games Over/Under 9.5';
match = regexUnderOver.exec(marketLabel);
browserReturn = match[3] + '/' + match[2] + ' ' + match[4] + ' Giochi Set ' + match[1];
しかし、私はbrowserReturn
変数に割り当てる前にデータを正しく注文する分割代入を使用することを好むだろう。私はMDNの規則に従うように努力しましたが、それは私には意味がありません。あなたが私が投稿した例を使って私に見せてもらえれば幸いです。以下の完全なコードは:
let marketLabel = 'Set 1 Total Games Over/Under 9.5';
const regexUnderOver = /^Set ([0-9.]+) Total Games (Over)\/(Under) ([0-9.]+)$/;
match = regexUnderOver.exec(marketLabel);
browserReturn = match[3] + '/' + match[2] + ' ' + match[4] + ' Giochi Set ' + match[1];
return browserReturn;
です 'marketLabel.replace(/^Setを返すこと([0-9。] +)$ /、$ 3/$ 2 $ 4ジオッチセット$ 1 ') 'あなたはお探しですか? –
ご不明な点がございましたら、ご容赦ください。これは、 'browserReturn = match [3] + '/' + match [2] + '' + match [4] + 'Giochi Set' + match [1];特に' match'配列を破壊する必要があります。 – DaveDavidson
最終的には、正確に何を持っておきたいですか? 'match'はすでにキャプチャされたすべてのテキストを含む配列です。インデックス経由で簡単にアクセスできます。 –