In article <3C02873C.978B559 / stud.ntnu.no>, "Kent Dahl"
<kentda / stud.ntnu.no> wrote:

> Really naive:
> 	legal = ["<br>","<hr>","<p>"]
> 	str.gsub(/<[^>]*>/){ |i|
> 		s = i.to_s;
> 		if legal.index(s) then
> 			s
> 		else
> 			s.gsub("<","&lt;").gsub(">","&gt;")
> 		end
> 	}
> 
> Output:
> 	"<br> <p> <hr> &lt;p align='center'&gt;"

Ah.  I'd forgotten that you could pass a block, rather than a fixed
string as the replacement text.

You've just gotta love blocks :-) !!

I don't think that's at all a naive approach.  It's precisely what I was
looking for.  However, if you ... or anyone else ... can see an
improvement to it, feel free to post a follow-up.

Thanks very much Kent.