Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

eraseBetween

開始点と終了点の間の部分文字列の削除

R2021b 以降

説明

newStr = eraseBetween(str,startStr,endStr) は、str 内の部分文字列 startStrendStr の間にある部分文字列を削除します。eraseBetween は、startStrendStr 自体は削除しません。

newStr = eraseBetween(str,startPos,endPos) は、str 内の文字の位置 startPosendPos の間にある部分文字列を、これらの位置にある文字も含めて削除します。

newStr = eraseBetween(___,Boundaries=bounds) は、演算子が削除する部分文字列に、前述の構文で指定した境界を含めるか、または除外します。bounds"inclusive" または "exclusive" として指定します。

メモ

eraseBetween 演算子は、C をアクション言語として使用する Stateflow® チャートではサポートされません。

すべて展開する

部分文字列を削除して、string "Hello!" を作成します。既定では、eraseBetween は境界の部分文字列を削除しません。

str = "Hello, world!";
newStr = eraseBetween(str,"Hello","!");

Stateflow chart that uses the eraseBetween operator in a state.

境界の部分文字列を削除するには、代わりにオプション Boundaries="inclusive" を使用します。

str = "Hello, world!";
newStr = eraseBetween(str,",","d",new,Boundaries="inclusive");

Stateflow chart that uses the eraseBetween operator in a state.

部分文字列を削除して、string "Hello!" を作成します。既定では、eraseBetween は境界の文字を削除します。

str = "Hello, world!";
newStr = eraseBetween(str,6,12);

Stateflow chart that uses the erasebetween operator in a state.

境界の文字が削除されないようにするには、代わりにオプション Boundaries="exclusive" を使用します。

str = "Hello, world!";
newStr = eraseBetween(str,5,13,new,Boundaries="exclusive");

Stateflow chart that uses the eraseBetween operator in a state.

入力引数

すべて展開する

入力 string。string スカラーとして指定します。リテラル文字列は二重引用符で囲みます。

例: "Hello"

先頭の部分文字列。string スカラーとして指定します。リテラル文字列は二重引用符で囲みます。

末尾の部分文字列。string スカラーとして指定します。リテラル文字列は二重引用符で囲みます。

先頭の文字の位置。正の整数として指定します。

末尾の文字の位置。正の整数として指定します。

境界のタイプ。"inclusive" または "exclusive" として指定します。bounds"inclusive" に設定すると、replaceBetween は、境界間にあるテキストを境界を含めて削除します。bounds"exclusive" に設定すると、replaceBetween は、境界間にあるテキストのみを削除します。

制限

バージョン履歴

R2021b で導入