If regexp stuff matter so much in the course of your programming for
a particular case, then using perl is a valid suggestion as it is
rightly seen as pretty much the best regexp engine so far (Oniguruma
[1]<sp?> has made some waves and may be able to best perl in the end,
but it’s not widely available and is an extension now, perhaps for
Ruby2/Rite it will be the built in regexp engine, who knows or dares
to dream).
So I don’t find it unreasonable to say to people who need to do a lot
of regexp work - “use perl”, it was practically designed for it. But
most of the time I find using regexp complicates things unnecessarily
[2].
Most of the time Ruby is good enough, if you are generating regexps
automatically, perhaps perl is the better choice as it will prevent
this exponential slowdown for you. To say that Ruby must be ‘fixed’
to allow you to write crappy regexps and have the engine take care of
it for you is in my opinion not the answer. If you’re going to use a
regexp, you should be aware of what you are doing. If for some
reason you generate a load of them automatically, then I think that
there could possibly be a better way of achieving your goals in ruby
(perhaps a dsl instead of treating everything as raw text?). And
finally Ruby might not be the right language to choose and you’d be
better off throwing your funky generated regexps at perl to handle.
All this may change as soon as Ruby2/Rite appears with Oniguruma, but
for now Ruby isn’t the best tool for every possible problem - and if
it’s a major worry for you, perhaps lend a hand with Onig… or
indeed write a perl-alike regexp engine extension - competition is
good
Kev
[1] http://www.geocities.jp/kosako3/oniguruma/
[2] Some people, when confronted with a problem, think ?I know, I?ll
use regular expressions.? Now they have two problems.?Jamie Zawinski,
in comp.lang.emacs