From: Rob Biedenharn Date: 2007-10-27T08:47:50+09:00 Subject: Re: Newlines included in bracket negation On Oct 26, 2007, at 7:23 PM, 7stud -- wrote: > Jesús Gabriel y Galán wrote: >> On 10/27/07, Phrogz wrote: >>>> => ["h", "", "day"] >>> h.+day/, which does not match. >> I need more sleep, for sure. I was of course thinking on the first >> "h" >> and the last "day". That explains it :-) > > A clue was in the capture results: > > rb(main):036:0> re = /(h)(.*)(day)/ > => /(h)(.*)(day)/ > irb(main):037:0> "happy\n\nbirthday".match(re).captures > => ["h", "", "day"] > > The fact that the (.*) matched nothing was an indication that > something > was amiss. Nothing amiss there at all. the * is match "zero or more times" and so it is perfectly fine to match zero occurrences of any character (except newline) between the 'h' and the 'day' -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com