Main Content

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

endsWith

string の末尾が部分文字列であるかの判別

R2021b 以降

説明

tf = endsWith(str,substr) は、string str の末尾が部分文字列 substr である場合は 1 (true) を返し、それ以外の場合は 0 (false) を返します。

tf = endsWith(str,substr,IgnoreCase=true) は、大文字小文字の違いを無視して、str の末尾が substr であるかどうかをチェックします。

メモ

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

すべて展開する

string "Hello, world!" の末尾が部分文字列 "World!" ではないため、値 0 (false) を返します。

str = "Hello, world!";
substr = "World!";
x = endsWith(str,substr);

Stateflow chart that uses the endswith operator in a state.

大文字小文字を区別しない場合、string "Hello, world!" の末尾が部分文字列 "World!" であるため、値 1 (true) を返します。

str = "Hello, world!";
substr = "World!";
x = endsWith(str,substr,IgnoreCase=true);

Stateflow chart that uses the endswith operator in a state, ignoring case.

入力引数

すべて展開する

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

例: "Hello"

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

例: "Hello"

制限

バージョン履歴

R2021b で導入