From: Eero Saynatkari Date: 2005-12-15T04:39:44+09:00 Subject: Re: string mangling Martin Pirker wrote: > Imagine an input string > aaaaabbccccceeebbbbbbbbbbeaaabaacccceeee... > > I have regexp for the parts a,b,c > and e can be considered as else. > > So how can I efficiently search/step through the string from left to > right, while calling for each section the fitting handler, kind of > > case section > /aaaa/ ... > > /bbb/ ... > > /cccc/ .. > > else > > end Aside from the oft-mentioned String#scan, you might look into using StringScanner (require 'strscan') from the stdlib. It is very good for more complex cases of scanning. Documentation is available, for example, at http://www.ruby-doc.org/stdlib. > Thanks for ideas! > Martin E -- Posted via http://www.ruby-forum.com/.