JavaScript Ganti semua karakter kecuali huruf dan angka

str.replace(/[^A-Za-z0-9]/g, "-")
Delightful Dotterel