I'm thinking of a bit different approach, because of your code doesn't catch all the inline urls...