Search code examples
rubyregexruby-1.8

How to match regexp starting from specific character index in Ruby 1.8?


In Ruby 1.9 I would use String#match(regexp,start_index). I'm sure there must be a (computationally efficient) equivalent in Ruby 1.8, but I can't find it. Do you know what it is?


Solution

  • As far as I can tell, there is no efficient way to match a Regexp against a large string, starting from an arbitrary index, in pure Ruby 1.8.

    This seems like a major flaw. I guess the moral of the story is: use Ruby 1.9!