From: Sami Samhuri Date: 2007-06-22T03:20:12+09:00 Subject: Re: Do You Understand Regular Expressions? On 6/21/07, Stephen Ball wrote: [...] > The /^.*/ pattern specifies that the string must start with anything > (e.g. it must have at least one character) and then zero or more > characters following. ^ anchors the match to beginning of a line or the beginning of the string. The second match fails because it's starting from the first point after "hello", where it left off. It says nothing about the content that follows. "".scan /^.*/ => [""] > The /.*$/ pattern has no restriction since the anchor is on the side > with the * character. So it's parsed as "zero or more of anything > before the end of the string". This is correct. First it finds the longest match it can in "hello". Then it finds nothing, but still anchored at the end of the line. Note that $ does not anchor the end of the string, but the end of each line within the string or the very end. \z matches the actual end of string, while \A does the same for the beginning. Hope this helps. -- Sami Samhuri