> I was trying to figure out how to take a string like this: > "http:// www.youtube.com/watch?v=QMuClxuWdH8" > and removing everything before (and including) the "=", > creating a new string with just "QMuClxuWdH8". > > At first I thought I would have to do something like: > > url = "http://www.youtube.com/watch?v=QMuClxuWdH8" > rev_url = url.reverse > rev_chomped = rev_url.chomp("=") > code = rev_chomped.reverse > > ...which doesn't actually work of course and is ugly anyway. > I have a feeling I'll need to use regular expressions to do > this, but I'm really lost when it comes to regex. How could I > do something like this? You could use regexps if you like, or you could take advantage of ruby's URI and CGI libraries: require 'uri' require 'cgi' url = URI::parse("http://www.youtube.com/watch?v=foobar") params = CGI::parse(url.query) code = params['v'][0] Regexps are more straightforward, URI/CGI libs are more robust. Either should do for ya. - donald