From: Phrogz Date: 2007-10-27T07:20:08+09:00 Subject: Re: Newlines included in bracket negation On Oct 26, 3:43 pm, "Jesús Gabriel y Galán" wrote: > There's also something I don't understand, similar to the above. > I always thought that in a non-multiline regexp, the dot didn't match > newlines (\n), so I don't understand this: > > irb(main):036:0> re = /(h)(.*)(day)/ > => /(h)(.*)(day)/ > irb(main):037:0> "happy\n\nbirthday".match(re).captures > => ["h", "", "day"] > irb(main):038:0> re = /(h)(.*)(day)/m > => /(h)(.*)(day)/m > irb(main):039:0> "happy\n\nbirthday".match(re).captures > => ["h", "appy\n\nbirth", "day"] > > I thought the first case wouldn't match. > Can anyone shed some light? The last four characters of the word "birthday" match the regexp / h.*day/, without crossing any newlines. Perhaps you were thinking of / h.+day/, which does not match.