Good question .. are you almost there!
$('.my-input').keyup(function() { this.value = this.value.replace(/[^A-Za-z0-9-]/g,"").toLowerCase();
Regex is not the most suitable tool for the bottom, use the built-in function. Your regex was good, but the replace function accepts one regex, and the replacement is a string, not a regex *.
(* replacement strings have some minor magic, but not enough for the bottom)
source share