I *think* this loop assumes that replacement doesn't include the original text more than once. If I understand this correctly, if we have the text 
"Mr. Bob goes to the store to see Ms. Bob", 
and we want to replace the first "Bob" with "BobBob" and the second with "Smith", this loop would first modify the string to be 
"Mr. Bob Bob goes to the store to see Ms. Bob"
The second time through the loop, it would become
"Mr. Bob Smith goes to the store to see Ms. Bob"
right?

If so, is that a situation we might find ourselves in? I don't remember, do definitions turn "mydef" into &lt;defn data-attr="mydef"&gt;mydef&lt/def&gt;?