------ art_60492_5823230.1171318097266 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jason, Thanks for the suggestion. Why would REXML be a good use though? -Dave On 2/12/07, Jason Roelofs <jameskilton / gmail.com> wrote: > > Well, maybe you can assume valid XML and parse the page with REXML. If > it's > not valid XML, well you can regex through for (off-the-cuff, probably > wrong) > /<param.*value .*)"/ and use the result. Someone more knowledgable in > Regexps can help you out if it comes to this. > > Jason > > On 2/12/07, Dave Hoefler <dhoefler / gmail.com> wrote: > > > > Hi there, > > > > I have a question about string search and replacement. Let's say I have > > this > > string that contains 2 <object> links for embedding youtube videos > amongst > > some other random text. > > > > string We've got some junk text here" + > > "<object width 425\" height 350\"><param name movie\" > > value http://www.youtube.com/v/qqsyXdj_p_I\"></param>" + > > "<param name wmode\" value transparent\"></param><embed > > src > > http://www.youtube.com/v/qqsyXdj_p_I\" > > type application/x-shockwave-flash\"" + > > "wmode transparent\" width 425\" > > height 350\"></embed></object>" + > > "And we've got some more junk text right here" + > > "<object width 425\" height 350\"><param name movie\" > > value http://www.youtube.com/v/yYqACgndOQA\"></param>" + > > "<param name wmode\" value transparent\"></param><embed > > src > > http://www.youtube.com/v/yYqACgndOQA\" > > type application/x-shockwave-flash\"" + > > "wmode transparent\" width 425\" > > height 350\"></embed></object>" + > > "more garbage text here" > > > > I'd like to get the value of the 'value' attributes (" > > http://www.youtube.com/v/qqsyXdj_p_I" and " > > http://www.youtube.com/v/yYqACgndOQA" respectively) and convert the > string > > into the following: > > > > We've got some junk text here > > <div id outube_qqsyXdj_p_I"></div> > > <script type ext/javascript"> > > var so ew SWFObject("http://www.youtube.com/v/qqsyXdj_p_I", > > "qqsyXdj_p_I", "425", "350", "6","","","","",""); > > so.write("youtube_qqsyXdj_p_I"); > > </script> > > And we've got some more junk text right here > > <div id outube_yYqACgndOQA"></div> > > <script type ext/javascript"> > > var so ew SWFObject("http://www.youtube.com/v/yYqACgndOQA", > > "yYqACgndOQA", "425", "350", "6","","","","",""); > > so.write("youtube_yYqACgndOQA"); > > </script> > > more garbage text here > > > > > > What would be the best library to use for parsing and replacing certain > > values in a string? I've done simple .gsub'ing before, but this seems to > > be > > a little more complicated ;-) > > > > Thanks, > > Dave Hoefler > > > ------ art_60492_5823230.1171318097266--