Provided you're iterating over each line you could use:
"newlines \r\n".gsub /(\r|\n)/, ''

HTH,
Alexander Schofield


Michael Hayes wrote:
> 
> It seems chop and chomp just won't do what I want.
> 
> My input has lines ending with \n or \r\n,
> possibly both in the same file, and there is
> also the possibility that the last line will
> not have either.
> 
> chop works for lines ending with \n or \r\n,
> but incorrectly removes the last character
> from the last line if it's unterminated.
> 
> chomp won't remove the last char from an
> unterminated line, but it only works on one
> type of record separator, so it won't handle
> \n and \r\n at the same time.
> 
> I can say:
> 
>     str.chomp.chomp("\r")
> 
> or make up some regexp horror, but I'd really
> like to know if there is some method that I've
> overlooked that can flexibly, reliably and
> safely remove a line terminator from any string.
> 
> --Mike