javascript - Add exception to regex -


I am using this code on which I stumbled on the 'clean' url with jquery:

  .replace (/ [^ \ w] + / g, '') // and .replace (/ + / g, '-')   

the first one Non-alpha removes - numeric characters, while the second gives a space in the dash

My question is if there is no way to exclude a character from #, this first in my situation. Replace () ?

Thank you.

  .replace (/ [^ \ W # \ /] + / g, ) // and    

Comments