5.3 String Operations

Last-modified: 2025-03-21 (金) 20:29:41

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 に次の関数が付属しています。

Common String Operations
Concatenating Strings
Splitting and Joining Strings
Searching in Strings
Searching and Replacing in Strings