Q:

To remove character between numbers and join the numbers which is removed

I want to remove alphabet characters between the numbers and I used this code
    <html>
    <body>

    <script>
            str = "3a45 12c3"
            myString = str.replace(/\D/g,'');
            alert(myString);
    </script>

    </body>
    </html>

I got the result 3 45 12 3, but I need 345 123. How should I get this?

A:

You could just remove the letters [a-z] instead of the non numbers \d.

var str = "3a45 12c3",
    myString = str.replace(/[a-z]/gi,'');

console.log(myString);

