From: Rob Biedenharn Date: 2007-06-18T20:56:16+09:00 Subject: Re: Parsing strings On Jun 18, 2007, at 4:03 AM, Dan German wrote: > come wrote: >> You could try : >> >> url='http://www.youtube.com/watch?v=OY8AIhbqPHo' >> url[/watch\?/]="" >> >> or with a postive lookahead : url[/watch\?(?=v=OY8AIhbqPHo)/]="" > > Thanks...that last expression worked well but I have one last > question: > I didn't realize this before but I also need to remove the equal sign > after the v and replace it with a forward slash ('/') so that it looks > like 'http://www.youtube.com/v/OY8AIhbqPHo' so just do that: url.sub(/watch\?v=/, 'v/') or if the variable wasn't always 'v': url.sub(/watch\?(.)=/, '\1/') -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com