I will be tempted to split all the properties into an array, as much as possible, maybe I would like some more. However, it will also provide easy access to the src property. So I would do something like this:
string iFrameString = "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/KRFHiBW9RE8\" frameborder=\"0\" allowfullscreen>"; //split properties based on spaces string[] tagProps = iFrameString.Split(new Char[]{' '}); //get the property out. string prop = "src=\""; string source = Array.Find(tagProps, x => x.StartsWith(prop, StringComparison.InvariantCultureIgnoreCase)); string ModifiedSource = source.Substring(prop.Length,source.Length - prop.Length);
The advantage of this is that you have all the other properties in your array, and you can get them if necessary.
source share