James Edward Gray II wrote: > I do understand the Regexp, but isn't that a look-ahead assertion at > the end? That's not supposed to consume characters, right? So why > doesn't the very next match start with the leading whitespace that > ended the last match? > > I know I just haven't got me head all the way around it yet. I'm > working on it... ;) > > James Edward Gray II No, at the end, it is not look-ahead assertion, the (?: ... ) still consume characters but without grouping. And when use String#scan and have group, the result will just return group anything not in the group will just ignore, for example: 'abcdef'.scan(/(.)./) # ==> [['a'], ['c'], ['e']] So the str.scan(/(.{1,30})(?:\s+|$)/) the part (?:\s+|$) will consume space characters but will not be part of scan result.