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-2025 Octave中文网

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