octave-maintainers
[Top][All Lists]
Advanced

[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: Sun, 11 Mar 2007 19:50:43 +0100
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

This isn't (yet) suitable for replacing strrep since the replacement argument x may have regular expression operators within it. You will need to escape them before applying the pattern. Something like the following might work:

  pattern = regexprep(x,'([*+([\\])','\\\1');
  t = regexprep(s,pattern,y);
>
> You will have to look up the syntax of the regular expression to figure
> out exactly which characters are significant and how to do replacement
> strings.

Right, I didn't thought about these special key combinations. Hhmmm... I'll give it another try the following days and if successful reply once again.

Also, if you can easily gather your strings into a cell array, you should be able to translate all of them at once and save even more time.

So we also could improve the strrep function into something like the regexprep function can already do, eg. strrep({"ab","ac"},"a","d"), right?

Thanks a lot,
Thomas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]