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…

useful regex

Date: ^(0[1-9]|1[0-2])/(0[1-9]|1\d|2\d|3[01])/(\d{4})$ mm/dd/yyyy   Email ^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$   IP ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)   URL http://(/%5B\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? exclude some url pattern, like do not want to url containing /pages/:  ‘’. This is useful in stylus chrome extension when do not want to apply style for certain urls. ^https?://!/pages/).)*$