From: Jim Freeze Date: 2005-12-06T05:15:18+09:00 Subject: Re: String split drops the delimiter Use (). irb(main):001:0> s="a,b,c,d" => "a,b,c,d" irb(main):002:0> s.split(/(,)/) => ["a", ",", "b", ",", "c", ",", "d"] On 12/5/05, basi wrote: > Hello: > > string.split drops the delimiter. Thus: > > data = " This is a declarative sentence. And is this a question? Yes! " > for sentence in data.split(/[.!?] /) > puts sentence > end > > gives > > This is a declarative sentence > And is this a question > Yes > > I'd like the result to retain the delimiter, thus: > > This is a declarative sentence. > And is this a question? > Yes! > > Any easy way to do this? > Thanks! > basi > > > -- Jim Freeze