From: Stefano Crocco Date: 2008-06-18T20:31:23+09:00 Subject: Re: gsub and regex On Wednesday 18 June 2008, Tom Cloyd wrote: > I'm trying to replace all /\n / with /\n/ in a string, but gsub won't > allow a regex as the replacement when a match occurs. I'm getting myself > considerably confused about data types and regex, and just plain need > some help. Is there some way to do this replacement, using gsub? > > Thanks, > > t. I'm not sure I understand you. Do you want to replace all newline charactes followed by a space with a single newline character? If so, you don't need regexps at all: str.gsub("\n ", "\n") I hope this helps Stefano