Carlos
8/3/2006 2:52:00 AM
Wes Gamble wrote:
> Wes Gamble wrote:
>
>>Something like:
>>
>> @html.scan(/~\^LNK:.*?\^~/mi).each do |link_line|
>> new_link_line = link_line.gsub(/[\s\r\n]/, '')
>> @html.gsub!(/#{link_line}/mi, new_link_line)
>> end
>
>
> This seems to work well:
>
> @html.scan(/~\^LNK:.*?\^~/mi).each do |link_line|
> new_link_line = link_line.gsub(/[\t\r\n]/, '')
> @html.gsub!(/#{Regexp.escape(link_line)}/mi, new_link_line) if
> link_line != new_link_line
> end
You can use a block with gsub:
@html.gsub!(/~\^LNK:.*?~/mi) { |s| s.gsub /\s/, '' }
or something like that.
Good luck.
--