Select single word between any HTML tag using regex - Javascript RegExp

Javascript examples for RegExp:Match HTML

Description

Select single word between any HTML tag using regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div id="main"> 
         <p class="yourword"> askdaksjdb </p> 
      </div> 
      <script>
var str = document.getElementById("main").innerHTML;
var res = str.match(/yourword/gi);
console.log(res);

      </script>  
   </body>/*  w  w w.  j  a  v  a 2  s.  com*/
</html>

Related Tutorials