# Converting youtube and google video embed HTML into a SWFObj

**URL:** <https://www.ruby-forum.com/t/converting-youtube-and-google-video-embed-html-into-a-swfobj/85327>\
**Category:** Rails\
**Created:** [February 12, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/converting-youtube-and-google-video-embed-html-into-a-swfobj/85327 "2007-02-12T17:57:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [February 12, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/converting-youtube-and-google-video-embed-html-into-a-swfobj/85327/1 "2007-02-12T17:57:33Z")

</div>

Hi there,

Is there a small ruby / rails library that formats youtube or google  
video  
HTML embed code into SWFObject ([SWFObject: Javascript Flash Player detection and embed script | deconcept](http://blog.deconcept.com/swfobject/))  
HTML?  
The code youtube and google video provide doesn’t always play nice in IE  
apparently (that’s what one of our CSS gurus at work told me).

So I’m looking to turn this (which doesn’t play nice in all browsers):

```
<object width="425" height="350">
    <param name="movie" value="http://www.youtube.com/v/qqsyXdj_p_I

```

"\>

into this:

The project I’m working on is a social community and we’re trying to  
keep  
the comments people post on profile pages as valid as possible.

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [February 12, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/converting-youtube-and-google-video-embed-html-into-a-swfobj/85327/2 "2007-02-12T17:58:33Z")

</div>

I forgot to mention, the whole site is in Rails… so that’s why I’m  
asking  
here 🙂

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [February 12, 2007, 10:35pm UTC](https://www.ruby-forum.com/t/converting-youtube-and-google-video-embed-html-into-a-swfobj/85327/3 "2007-02-12T22:35:18Z")

</div>

Here’s a little more info on the issue:

Let’s say I have this string that contains 2 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="[- YouTube](http://www.youtube.com/v/qqsyXdj_p_I%5C%22%3E%3C/param%3E%22) +  
“\<param name="wmode" value="transparent"\>\<embed  
src="  
[- YouTube](http://www.youtube.com/v/qqsyXdj_p_I%5C)”  
type="application/x-shockwave-flash"” +  
“wmode="transparent" width="425"  
height="350"\>” +  
“And we’ve got some more junk text right here” +  
“\<object width="425" height="350"\>\<param name="movie"  
value="[- YouTube](http://www.youtube.com/v/yYqACgndOQA%5C%22%3E%3C/param%3E%22) +  
“\<param name="wmode" value="transparent"\>\<embed  
src="  
[- YouTube](http://www.youtube.com/v/yYqACgndOQA%5C)”  
type="application/x-shockwave-flash"” +  
“wmode="transparent" width="425"  
height="350"\>” +  
“more garbage text here”

I’d like to get the value of the ‘value’ attributes ("  
[- YouTube](http://www.youtube.com/v/qqsyXdj_p_I)" and "  
[- YouTube](http://www.youtube.com/v/yYqACgndOQA)" respectively) and convert the  
string  
into the following:

We’ve got some junk text here

And we've got some more junk text right here

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 H.
