Get Selected str.replace Value From Regex - Javascript String Operation

Javascript examples for String Operation:String Replace

Description

Get Selected str.replace Value From 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(){/* w  ww .  j a va 2  s.co m*/
var myCode = "[i]test[/i] something more and [b]test[/b]";
myCode = myCode.replace(/\[(b|i|p)\](.*?)\[\/(b|i|p)\]/g, "<$1>$2</$3>");
console.log(myCode);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials