strrep
查找并替换子字符串
说明
示例
输入参数
算法
strrep函数不会查找空字符向量或空字符串进行替换。即,当str和old均包含空字符向量 ('') 或空字符串 ("") 时,strrep不会将空字符向量或字符串替换为new的内容。在替换文本之前,
strrep会像strfind函数一样查找str中的所有old实例。对于重叠模式,strrep执行多次替换。
替代功能
更新使用 strrep 的代码以改用 replace。例如:
| 不推荐 | 推荐 |
|---|---|
str = "ababa"; newstr = strrep(str,"b","c") newstr =
"acaca" | str = "ababa"; newstr = replace(str,"b","c") newstr =
"acaca" |
扩展功能
版本历史记录
在 R2006a 之前推出