Get part of a string using regex match - Javascript jQuery

Javascript examples for jQuery:String

Description

Get part of a string using regex match

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.2.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from ww  w.j  av  a 2 s.  c  o  m*/
$(function() {
    console.log($("div").attr("id").match(/[\d]+$/));
});
    });

      </script> 
   </head> 
   <body> 
      <div id="block-id-45"></div>  
   </body>
</html>

Related Tutorials