e$B1sF#$G$9!#e(B
sub e$B$de(B gsub e$B$OBh0l0z?t$,J8;zNs$N;~!"$=$NJ8;zNs$re(B
rb_reg_quote
e$B$7$?$b$N$re(B rb_reg_regcomp e$B$G%-%c%C%7%e$7$^$9!#e(B
$ time LANG=C ./ruby -ve ‘n = “\u3042” * 1000; 30000.times { “”.sub!(n,
“”) }’
ruby 1.9.0 (2008-02-14 revision 15475) [i686-linux]
real 0m1.340s
user 0m1.300s
sys 0m0.030s
e$B$G$b!"$=$NJ8;zNs$,e(B ascii
e$B$N$_$G$"$k>l9g$O%-%c%C%7%e$K<:GT$9$ke(B
e$B$h$&$G$9!#e(B
$ time LANG=C ./ruby -ve ‘n = “abc” * 1000; 30000.times { “”.sub!(n, “”)
}’
ruby 1.9.0 (2008-02-14 revision 15475) [i686-linux]
real 0m32.840s
user 0m32.560s
sys 0m0.030s
rb_reg_quote e$B$NJV$7$?J8;zNs$N%(%s%3!<%G%#%s%0$,e(B ASCII-8BIT
e$B$G!“e(B
e$B%-%c%C%7%e$Ne(B Regexp e$B$N%(%s%3!<%G%#%s%0$,e(B US-ASCII
e$B$G?)$$0c$C$Fe(B
e$B$$$k$?$a!”%-%c%C%7%e$Ne(B Regexp e$B$,:FMxMQ$5$l$J$$$h$&$G$9!#e(B