「$」は文字列の末尾であることを表します。
検索対象文字列の末尾の部分にマッチングさせたいときなどに、「$」で文字列の末尾であることを指定できます。
// 検索対象文字列
var str1 = "abcxyzdefghi";
var str2 = "abcdefghixyz";
// 検索実行および結果出力
document.write("「abcxyzdefghi」の抽出結果: ", str1.match(/xyz/));
document.write("<br>「abcdefghixyz」の抽出結果: ", str2.match(/xyz/));
// 検索対象文字列
var str1 = "abcxyzdefghi";
var str2 = "abcdefghixyz";
// 検索実行および結果出力
document.write("「abcxyzdefghi」の抽出結果: ", str1.match(/xyz$/));
document.write("<br>「abcdefghixyz」の抽出結果: ", str2.match(/xyz$/));