Hi,

In message "[ruby-talk:20604] String.subst[!] RCR"
    on 01/08/31, "Aristarkh A Zagorodnikov" <xm / w3d.ru> writes:

|	I have a proposal ;) Not sure eveyone will need it - maybe everyone is
|satisfied with regexp matching performance, but sometimes I need a lot of
|string replacements which work fast, and do NOT need complex regexp matching
|rules. I'm pretty sure that regexp matching isn't the fastest operation out
|there (at least I believe it involves some kind of regexp compilation). So,
|I'm proposing the following two methods (to be built in C).

You mean you want "str.sub(pat, new)" without using regular
expression?

Regular expression search is pretty fast for most of the cases
(especially for fixed patterns).  It uses BM search inside. 
As a result, str.sub(/foo/, 'bar') is often faster than your
str.subst('foo','bar').

							matz.