I'm trying to write a regex that will look for the width and height attributes in a string (which will always be an html iframe) and replace the values that it has.
What I have is a string where ### could be any value, and not necessarily always 3 digits.
string iFrame = <iframe width="###" height="###" src="http://www.youtube.com/embed/xxxxxx" frameborder="0" allowfullscreen></iframe>
I want to end up with set values for the width and height:
<iframe width="315" height="215" src="http://www.youtube.com/embed/xxxxxx" frameborder="0" allowfullscreen></iframe>
I tried this, but am not good with regular expressions:
iFrame = Regex.Replace(iFrame, "width=\".*\"", "width=\"315\"");
iFrame = Regex.Replace(iFrame, "height=\".*\"", "height=\"215\"");
which resulted in:
<iframe width="315" allowfullscreen></iframe>
which is not what I want. Can someone help me?