From: James Edward Gray II Date: 2005-09-14T23:59:08+09:00 Subject: Re: Quick and dirty word wrapping. On Sep 14, 2005, at 9:48 AM, Gavin Kistner wrote: > On Sep 14, 2005, at 8:38 AM, James Edward Gray II wrote: > >>> str.scan(/(.{1,30})(?:\s+|$)/) >>> >> I'm still puzzling out how that works... >> > > Up to 30 characters, but there has to be whitespace after it (to > keep it from splitting in the middle of the word) or be the very > end of the string. The greedy regexp will grab all 30 if it can > find them with whitespace after, otherwise it will backtrack until > it finds the right spot. 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