I assume that your example of
Code:
<p>'What if,' she said, 'there's something like this?'</p>
got changed into
Code:
<p>‘What if,' she said, 'there's something like this?’</p>
? If that is the case, then the problem lies in step 3 above - I used a non-greedy mode (.*?) while you used a greedy mode (.*).