Javascript examples for RegExp:Match URL
Find and replace using regex in url
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w ww . ja v a 2s.c om*/ var str = '[video=youtube;RrI-3vt5VnE]https://www.youtube.com/watch?v=RrI-3vt5VnE[/video]'; var pattern = /\[video=youtube;([^\]]+)\].*\[\/video\]/; var output = str.replace(pattern,'[MEDIA=youtube]$1[/MEDIA]'); console.log(output); } </script> </head> <body> </body> </html>