From: GianFranco Bozzetti Date: 2010-08-04T17:35:39+09:00 Subject: Re: Get rid of extra, blank lines via html parsing? Use the String methods: s. strip!, s.gsub! and s.squeeze as in the following snippet: # no-white.rb - remove empty lines and sequences of blanks # from a text file fh = File.open('6HWDs5dm.txt') while( !fh.eof) line = fh.readline.chomp # remove leading and trailing blanks line.strip! # skip empty lines next if line == '' # convert tab chars to blanks line.gsub!(/\t/,' ') # substitute a single blank for a sequence of blanks line.squeeze!(' ') # add code to process line if needed puts line end fh.close exit(0) HTH gfb "David Ainley" wrote in message news:a8de6e7e2af61a043990f1a86a62f009@ruby-forum.com... > So I am trying to get some information from a snippet of html > (http://pastebin.com/iTXyxQ0j), and im using doc.inner_text to get the > important parts, but when I do so I get an odd amount of spacing > (http://pastebin.com/6HWDs5dm). is there a way where I can get rid of > all that extra spacing so I can just print the output and it looks > clean? possibly something like > > pino > 0.2.11-ubuntu0~lucid > troorl > (2010-07-04) > > pino > 0.2.10-ubuntu0~karmic > troorl > (2010-05-27) > > that? or can i get each piece of text and add it to an array? if i do > that while its got all that odd spacing, is that spacing a piece of the > variable? or is it juts the text? > > thanks guys! > -- > Posted via http://www.ruby-forum.com/. >