How can we replace all special characters with _, provided if there are continuous special characters then they should be replaced with only one _. Example below.
| I/P. | O/P |
|---|---|
| abc@de# | abc_de_ |
| abc@.de | abc_de |
I am using str.replace(/[^\w\s]/gi, '_'), which works fine for non continuous characters.