From: Robert Klemme Date: 2006-01-11T18:58:06+09:00 Subject: Re: Finding a sentence (more than one word & punctuation (, . ;)) in a string? Kev Jackson wrote: > given this string > > " message the message > to echo. Yes, unless data > is included in a character section within this element. " > > how can I get this result > > ["message", "the message to echo.", "Yes, unless data is included in a > character section within this element."] > > ? > > I've tried scan + regexp, but the best I've got so far is > > [["message"]] > > with this > > r.scan(/\">(\w+\s*)<\/td>/) > > Thanks > Kev If you really want sentences, this will work: >> s.scan /\w+(?:[\s,]+\w+)*[.;?!]/ => ["the message\nto echo.", "Yes, unless data is\nincluded in a character section within this element."] >> s.scan /\w+(?:,?\s+\w+)*[.;?!]/ => ["the message\nto echo.", "Yes, unless data is\nincluded in a character section within this element."] Kind regards robert