JavaScript Zastąp wszystkie znaki oprócz liter i cyfr

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