5.3 字符串操作

Octave 支持广泛的字符串操作函数。因为字符串本质上是一个矩阵,因此可以使用标准运算符进行简单的操作。以下示例展示了如何用下划线替换所有空白字符。

quote = ...
  "First things first, but not necessarily in that order";
quote( quote == " " ) = "_"
⇒   quote =
    First_things_first,_but_not_necessarily_in_that_order

对于更复杂的操作,如搜索、替换和通用正则表达式,Octave 附带了以下函数。

版权所有 © 2024-2026 Octave中文网

ICP备案/许可证号:黑ICP备2024030411号-2