I want to replace (javascript) all chars that not in regex pattern with '_' Example
string: #he57/h 
Pattern: /^[_a-zA-Z][_a-zA-Z0-9]*$/ 
Expected result: _he57_h 
I tried
var str = "#he57/h";
var res = str.replace(/^[^_a-zA-Z][^_a-zA-Z0-9]*$/g, "_");
console.log(res);But its not do the work.
 
    