Javascript examples for String Operation:String Replace
Get Selected str.replace Value From Regex
<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>