From: HarryO Date: 2001-11-26T22:05:53+09:00 Subject: [ruby-talk:26506] Re: String editing question In article <3C02873C.978B559@stud.ntnu.no>, "Kent Dahl" wrote: > Really naive: > legal = ["
","
","

"] > str.gsub(/<[^>]*>/){ |i| > s = i.to_s; > if legal.index(s) then > s > else > s.gsub("<","<").gsub(">",">") > end > } > > Output: > "


<p align='center'>" 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.