I'm looping through the input string, extracting the iframe data with a substr call. The offset and length of the substr call are derived from the indexes of the beginning and ending iframe tags, which are updated at each iteration of the loop.

The indexes of the opening and closing iframe tags themselves are found by starting the search at the index of the tag immediately proceeding it. The loop continues until an opening iframe tag can't be found.