A little help needed with using numbers from an html file

Hello,

I am trying to make an animation that gets its content from an html file. In the code below I am looking for an image tag in the html file. If it’s there I want to then look for the width attribute and grab the number from it. I can’t figure out a way to easily do it. I thought about looking for the closing double quote but what happens it the coder uses a single quote.

Can anyone get me back on track here?

Thanks for the look.


//If an image is called out in the html file, get its width and height
 if (loadedHTMLFile.search("<img ") > 0)
 {
  var imageStartIndex:int = loadedHTMLFile.indexOf("<img ");
  var imageURLtoLong:String = loadedHTMLFile.substr(loadedHTMLFile.indexOf("<img "));
  var imageEndIndex:int = imageURLtoLong.indexOf(">");
  var imageURL:String = loadedHTMLFile.substr(imageStartIndex, imageEndIndex +1);
  
  var widthStringStart:int = imageURL.indexOf(" width");
  var widthAttrtoLong:String = imageURL.substr(imageURL.indexOf(" width"));
 
  var regexNumber:RegExp=/[0-9]/g;
  var widthAttrStart:int = widthAttrtoLong.search(regexNumber);
  
  for(var i:int = 0; i < widthAttrtoLong.length; i++)
  {
   if(0 < int(widthAttrtoLong.substr(widthAttrStart, i)) < 1000)
   {
    //var numberCheck:int = widthAttrtoLong.substr(widthAttrStart, i);
    
    trace(widthAttrtoLong.substr(widthAttrStart, i));
   }
  }
 }