Hi guys thanks for pay attention to this. Well im trying to replace every full youtube url with a word. An Example:
http://www.youtube.com/watch?v=lDC0gdrcauI Should be replaced with the word "Video"
http://www.youtube.com/watch?v=ef0wk8QoA34&feature=g-all-u Should be replaced with the word "Video"
Here is my code thus far. HTML:
<p>My brother is great.</p>
<p>http://www.youtube.com/watch?v=ef0wk8QoA34</p>
And JS:
(function($) {
$(function(){
var thePage = $("body");
thePage.html(thePage.html().replace(/My brother/g, 'My Pig').replace(/youtube.com/g, 'video'));
});
})(jQuery)
A JSFiddle can be found here: http://jsfiddle.net/QmRc7/2/
So if you could help me with that ill be great! Thanks!
PS: Sorry guys my post was edited not by me :/
Solved! I just add this and works great +1 for everyone!:
.replace(/(www.)?youtu(be\.com|\.be)\/(watch\?v=)?([A-Za-z0-9._%-]*)(\&\S+)?/g, '')