Convert the text to an int with regex - Javascript RegExp

Javascript examples for RegExp:Match Number

Description

Convert the text to an int with regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from www . j a va  2 s. com
var cash = document.getElementsByClassName('cash')[0].innerHTML;
var parser = parseFloat(cash.replace(/[^0-9|^.]/g, ''));
console.log(parser);
    }

      </script> 
   </head> 
   <body> 
      <div class="cash">
         1,123.23
      </div>  
   </body>
</html>

Related Tutorials