0

How can I replace all spaces with a dash, remove all non-alphanumeric characters EXCEPT comma and period, and lowercase all in the same string?

var cspID = thisTxt.replace(/\W+/g, '-').toLowerCase(); 

[^,.] replaces everything except comma and period, but how do I combine this functionality?

I need to pull ID's from sharepoint tags and create anchor tags for them. I am able to replace the spaces with dashes and lowercase the strings, but it also strips out the commas and periods. For some reason sharepoint leaves those in the id's it generates...

three7studio
  • 86
  • 10

0 Answers0