Javascript examples for RegExp:Match Number
Remove all non-numeric characters from a variable using regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w .j a v a 2 s .c o m deduct(); function deduct(){ var getamt= "Amount is 1000"; //eg: Amount is 1000 var value1 = 100; var getamt2 = value1 - getamt.replace( /^\D+/g, ''); console.log(getamt2); } } </script> </head> <body> </body> </html>