> Ideally, portions of the string that look like /<a href[^>]+/ > and /<img src^>]+/ would be excluded from the html encoding... OK, so I screwed up the regex... I think you get the idea :)