Converting PHP RegEX Sanitize String Function to Javascript

Solution:

Here is solution please check regex pattern :

 

function sanitizejs(str){
    return str.trim().replace(/[^A-Z0-9]+/ig, "_").toLowerCase();
}

console.log(sanitizejs('Test String - 20AS(AE)0121 '))