Use Regular expression to replace middle of multiline string - Javascript String Operation

Javascript examples for String Operation:String Replace

Description

Use Regular expression to replace middle of multiline string

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   w w  w  .j  a  v a 2  s  . c o m
document.body.innerHTML = document.body.innerHTML.replace(/"[\s\S]*?<a>\w+: (.+)<\/a>[\s\S]*?"/g, '$1');
    }

      </script> 
   </head> 
   <body>
       " 
      <a>Customer: John Doe</a>
       " 
      <br> 
      <br> 
      <br>
       " 
      <a>Customer: John</a>
       "  
   </body>
</html>

Related Tutorials