From: Seth Kurtzberg Date: 2003-03-12T04:59:09+09:00 Subject: Re: scanning strings You can use split with a regular expression. Or you can use a regular expression with defined subexpressions. Either way you can get the results you are looking for. On Tuesday 11 March 2003 12:51 pm, MikkelFJ wrote: > I want to scan a string for breaks. I want to pick both the breaks and the > text in between. > If I use String#each I loose the space. > If I use String#scan, I get into a fairly involved expression with two > submatches > where the second submatch is almost exactly the negation of the first > submatch. > > Is it it possible to break a string such that you get a both the match and > the text before last match, if any? > > If not, wouldn't that be a useful feature in Ruby? > > One simple example is processing a line at a time, but you want to keep the > break style of the source text which could be , or . > > > Mikkel -- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com