The below code will help to do so.
<html>
<head>
<script>
function test(){
//alert("6abc67*uv3$%^78*(op23".replace(/[\D]/g, ""));
//alert("6abc67*uv3$%^78*(op23".replace(/\D/g, ""));
alert("6abc67*uv3$%^78*(op23".replace(/[^{0-9}]/g, ""));
}
</script>
</head>
<body>
<input type="button" value="Test" onclick="test()" />
</body>
</html>
\D matches a character that is not a numerical digit and the non digit characters will be replaced by an empty string resulting in only the digits in a string.The
g at the end of the regular expression literal is for "global" meaning that it replaces all matches. So all the 3 shown above will work