Assume I have the following URL stored in variable called content:
http://www.example.com/watch?v=4444444&feature=related
Problem:
- I need to replace watch?v= with embed/
- I need to erase whatever comes after &
The final output would look like:
http://www.example.com/embed/4444444
I tried these two steps but didn't work:
content = content.replace('/watch?v=/', 'embed/');
content = content.replace('&*/g','');
The URL in page source code appears as:
http://www.example.com/watch?v=4444444&feature=related