>   Also keep in mind that =~ is generally a lot faster then .match since
> match has to build the full MatchData object even if you do not use it.

With =~ the MatchData can still be obtained from $~

Interestingly, not referencing the MatchData *does* give a big speed 
improvement.

$ time ruby -e '5_000_000.times { /b/.match("abc") }'

real    0m28.699s
user    0m28.490s
sys     0m0.024s

$ time ruby -e '5_000_000.times { /b/ =~ "abc"; $~ }'

real    0m28.119s
user    0m27.910s
sys     0m0.024s

$ time ruby -e '5_000_000.times { /b/ =~ "abc" }'

real    0m14.311s
user    0m14.285s
sys     0m0.008s

$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
-- 
Posted via http://www.ruby-forum.com/.