Test a variable with a regExp, and show returned value - Javascript RegExp

Javascript examples for RegExp:RegExp test

Description

Test a variable with a regExp, and show returned value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script>
function changeCode(){/*from   ww  w . j  a  v a2  s  . c o  m*/
    var field = document.getElementById("fld");
    console.log(field.value.match(/\d+px/g));
}

      </script> 
      <textarea id="fld"></textarea> 
      <button id="btn" onclick="changeCode();">Get</button>  
   </body>
</html>

Related Tutorials