From: Ruby Newbee Date: 2010-01-04T18:22:24+09:00 Subject: Re: Is ruby's regex slower? On Mon, Jan 4, 2010 at 5:07 PM, Ayumu Aizawa wrote: > Hi Jenn. > > Its interested ;) > > How's it? > Thanks for the reminding, I got your meanings. This time I used a compiled regex for both ruby and perl, the speed is still different: # cat regex_compile.rb #!/usr/bin/ruby regex = /href="http:\/\/(.*?)\/.*" target="_blank"/ File.open("index.html") do |f| f.each_line do |c| puts $1 if c =~ regex end end # cat regex_compile.pl #!/usr/bin/perl open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/o; } close HD; # time ruby regex_compile.rb > /dev/null real 0m0.011s user 0m0.008s sys 0m0.004s # time perl regex_compile.pl > /dev/null real 0m0.003s user 0m0.000s sys 0m0.000s