Mask ssn using regular expression : I want to mask ssn number. I tried this code but it is not working

    var r = new RegExp('?:\d{3})-(?:\d{2})-(\d{4}');    
    var str = '123-12-1234';        
    var result = str.replace(r,'#########'); 

       

Do i need to change the expression? 

Thanks in advance