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

You could use String#scan to find bits that find sections that match any of your requirements, then check to see which matched (your patterns could be more complicated, but still distinguishable from one another)

str = 'aaaaabbccccceeebbbbbbbbbbeaaabaacccceeee'

a_rx = /a+/
b_rx = /b+/
c_rx = /c+/

str.scan(/(?:#{a_rx}|#{b_rx}|#{c_rx})/) do | part |
  case part
  when a_rx
    # ...
  when b_rx
    # ...
  when c_rx
    # ...
  end
end