From: James Edward Gray II Date: 2005-09-15T02:11:11+09:00 Subject: Re: Quick and dirty word wrapping. On Sep 14, 2005, at 9:59 AM, James Edward Gray II wrote: > 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? > Answering my own dumb question, "No James, that's simple clustering not a look-ahead. Get your Regexp symbology right man!" Clustering does consume characters of course, so it now all makes sense to me. I guess it was just too early in the morning for me... ;) James Edward Gray II