HI guys I can’t seem to find a way to find this sertain url in content and replace it. All works when URL does not contain parameters but can not make it work otherwise.
Find and repace this: **https://www.youtube.com/watch?v=hMZ0Q7Yio8g&list=RDhMZ0Q7Yio8g&start_radio=1**
in this string:
**hello this is a test string replace me https://www.youtube.com/watch?v=hMZ0Q7Yio8g&list=RDhMZ0Q7Yio8g&start_radio=1 content continues!**
Well the Syntax highlighter is going to start you off first of all.
/https://www.youtube.com/watch?v=hMZ0Q7Yio8g&list=RDhMZ0Q7Yio8g&start_radio=1/g
/ is your delimiter. So it can’t appear in the string. But it does. 3 times.
You need to escape the forward slashes in the middle of the string with backslashes. \/
Secondly, inline regexes in javascript dont have quotes around them. What you’ve done there is told your code to find a literal string /https://www.youtube.com/watch?v=hMZ0Q7Yio8g&list=RDhMZ0Q7Yio8g&start_radio=1/g
Thirdly… if you’re finding exactly that string, you dont need a regex unless it will appear more than once. (Or… yaknow… replaceAll?)
EDIT: Woops. Knew i’d miss at least one… Fourthly, the . and ?s are special characters in regexes, so you’ll need to escape that too.