[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another implementation for strrep
From: |
Thomas Treichl |
Subject: |
Re: Another implementation for strrep |
Date: |
Sat, 10 Mar 2007 10:10:52 +0100 |
User-agent: |
Thunderbird 1.5.0.10 (Macintosh/20070221) |
Paul Kienzle schrieb:
Use regexprep and you get rid of the loop as well.
- Paul
Wow, that's really fast,
octave:7> tic, for CNT = 1:10000, strrep ("This is a % test string", ...
> "%", "AAAA"); end, toc
Elapsed time is 9.649048 seconds.
octave:8> tic, for CNT = 1:10000, _strrep_ ("This is a % test string", ...
> "%", "AAAA"); end, toc
Elapsed time is 1.654892 seconds.
Thanks Paul, at the moment I need to do a lot of fast string replacements.
Bye, Thomas
function t = _strrep_ (s, x, y)
if (nargin != 3), print_usage (); endif
if (! (ischar (s) && ischar (x) && ischar (y)))
error ("strrep: all arguments must be strings");
endif
t = regexprep (s, x, y);
endfunction