From: James Gray Date: 2008-09-02T00:52:35+09:00 Subject: Re: Looking for a regular pattern On Sep 1, 2008, at 4:27 AM, David A. Black wrote: > Hi -- > > On Mon, 1 Sep 2008, Peter Hickman wrote: > >> Zhao Yi wrote: >>> Sebastian Hungerecker wrote: >>>> Zhao Yi wrote: >>>>> I think this is better [.\s] >>>> No, it's not. >>> Why? It should match any character. >> From the docs, http://www.ruby-doc.org/docs/UsersGuide/rg/regexp.html >> >> |\s| space character; same as |[ \t\n\r\f] >> >> That is not any character it is only whitespace. > > Yes, but [.\s] is a character class, consisting of any character other > than \n, plus any space including \n. So it will match any character. No, it's not: >> "a" =~ /[.\n]/ => nil The period loses its special meaning inside a character class, so that class literally matches a period or a newline character. James Edward Gray II