regex dash – inside bracket []

We have a requirement to remove some illegal character in file name like slash etc… So I put on a regex in our code: [^a-zA-Z0-9.-_] I assume the above regex will match everything that is not number/char/dot/dash/underscore. Turns out I was wrong! The – is special case inside […] that is used for range. It should be…