Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Match then Replace


astupidname - 9:22 am on Jul 19, 2009 (gmt 0)


.match() returns either an array of found match/matches or null, so if the returned match is not null, access by index number. Try:

var youtube = 'http://www.youtube.com/watch?v=44xb9nb2P7g';
youtube = youtube.match(/v=(\w+)/);
youtube = (youtube !== null) ? youtube[0].replace(/v=/,'') : null;


Thread source:: http://www.webmasterworld.com/javascript/3954941.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com