From: Tom Cloyd Date: 2009-02-07T07:08:58+09:00 Subject: Re: regex \s == \n??? David A. Black wrote: > Hi -- > > On Fri, 6 Feb 2009, Tom Cloyd wrote: > >> Stefano, Joe - thank you! I'm only just getting into regex, so I get >> easily lost. You solved my problem - each in different ways. A lot of >> bang for the buck, indeed! > > Another variant: > > a.gsub(/[^\S\n]+/, " ") > > That character class means "all characters that are not a non-space or > \n." (The ^ is the "not" part.) > > You might also be able to use squeeze: > > p "abc def \n ghi\n".squeeze # "abc def \n ghi\n" > > though that's going to be less versatile if you're dealing, say, with > tabs. > > > David > Thanks, David. I continue to be amazed by the depth of your knowledge, and outright cleverness. In pursuing this simply problem I'm inadvertently learning a lot. I'm grateful. Thanks for your contribution that process! t. -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist Bellingham, Washington, U.S.A: (360) 920-1226 << tc@tomcloyd.com >> (email) << TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~