ASP, vbscript - regex replace

I want to replace some text in the following code that users can insert in a CMS system:

<object width="480" height="385"><param name="movie" value=""></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

As you can see this is from Youtube to embed a video.

I want to replace these strings in the code:


These strings can be variable. For instance someone can just insert: width="2480"

I want to avoid people from doing that.

Those 2 stings need to be replaced by:


Can anyone give some code to do that ?

Also any idea's how to do a basic validation that the code people insert is indeed to embed a Youtube video ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Maybe something like this:
oldText="<object width=""480"" height=""385""><param name=""movie"" value=""""></param><param name=""allowFullScreen"" value=""true""></param><param name=""allowscriptaccess"" value=""always""></param><embed src="""" type=""application/x-shockwave-flash"" allowscriptaccess=""always"" allowfullscreen=""true"" width=""480"" height=""385""></embed></object>"

msgbox oldText


msgbox newText

Function FixDimensions(myText)
	'Set objRegEx = CreateObject("VBScript.RegExp")
	Set objRegEx = New RegExp

	'objRegEx.MultiLine = True 
	objRegEx.Pattern = "width=""+[0-9]+"""
	Set colMatches_w = objRegEx.Execute(myText)  
	If colMatches_w.count > 0 then myText=objRegEx.Replace(myText,"width=""320""")
	objRegEx.Pattern = "height=""+[0-9]+"""
	Set colMatches_h = objRegEx.Execute(myText)  
	If colMatches_h.count > 0 then myText=objRegEx.Replace(myText,"height=""200""")


End Function

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dutch_guyAuthor Commented:
Works great! Thanks alot !
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.