I have an HTML file that is in a string.

I want to use gsub! to recursively remove any embedded newlines and 
whitespace within two known delimeters.

Given a string that includes this kind of string:

~^LNK:http://slashdot.org/login.pl?op=newuserform~
			Create a new account
		^~

I want to replace the above with:

~^LNK:http://slashdot.org/login.pl?op=newuserform~Create a new account^~

(stripping out the newlines and whitespace)

Having trouble writing the regex for this.

I think I want something like:

/~\^LNK:.*?([\s\r\n])+.*?\^~/

that I could use in:

str.gsub!(/~\^LNK:.*?([\s\r\n])+.*?\^~/, '')

to replace all of the whitespace, or potential newline characters with 
null strings.

But I don't think this will work because I really need to loop _within_ 
each substring of my large HTML string.  The thing about gsub is that it 
will substitute the entire matched string.

Do I need to scan out the ~^LNK.*?^~, operate on those and then put them 
back into the larger string?

I'm not sure I'm asking this very well, so I apologize if that's the 
case.

Thanks,
Wes

-- 
Posted via http://www.ruby-forum.com/.