From: HarryO Date: 2001-11-26T20:45:46+09:00 Subject: [ruby-talk:26495] Re: String editing question In article <3C027DEF.218F4875@stud.ntnu.no>, "Kent Dahl" wrote: > HarryO wrote: >> So, can anyone suggest the right way to approach this? > > Not the "right way", but one that I, as a I find myself using > "pseudo-xml" in lots of posts, prefer, is that recognized legal tags are > entered as HTML, and all other instances of < and > are replaced with > < and > That was the sort of thing I was getting at if I approached it from the point of view of the UNacceptable tags. > This seems somewhat easier to implement too. You could regexp on any > occurance of /<.*>/, check if the contents are listed in the "allowed > tags" list, and gsub the < and > if not. If there are many tags in the string, I'd have to do the regexp matching multiple times. How do I avoid it simply matching the same tags over and over again (in the case where the regexp matches an acceptable tag, rather than an unacceptable one)? > Of course, this is just of the top of my (quite often faulty) head. I'll bet it's not faulty as often as mine !!