Main Content

textBoundary

テキストの先頭または末尾に一致する

R2020b 以降

説明

pat= textBoundaryは、テキストの先頭または末尾に一致するパターンを作成します。textBoundaryは、~演算子を使用して否定できます。否定した場合、textBoundaryは、テキストの先頭または末尾以外のすべての文字に一致します。

pat= textBoundary(type)は、テキストの先頭と末尾のどちらに一致させるかを指定します。typeは、'start''end''either'(既定値) のいずれかです。

すべて折りたたむ

textBoundaryを使用して、テキストの先頭または末尾に一致させます。

複数のテキストを含む string 配列を作成します。各テキストの先頭にある単語に一致するパターンを作成します。

txts = ["This is the first piece of text""Here is the second"“现在的re are three"];pat = textBoundary + lettersPattern;

パターンを抽出します。

firstWords = extract(txts,pat)
firstWords =3x1 string"This" "Here" "Now"

textBoundary"end"オプションを使用して、テキストの指定した終点に一致させます。

複数のテキストを含む string 配列を作成します。各テキストの末尾にある単語に一致するパターンを作成します。

txts = ["This is the first piece of text""Here is the second"“现在的re are three"];帕特= lettersPattern + textBoundary ("end");

パターンを抽出します。

lastWords = extract(txts,pat)
lastWords =3x1 string"text" "second" "three"

~演算子を使用して、textBoundaryを否定します。これは、2 つの文字がどちらもテキストの先頭または末尾でない場合に、その 2 つの文字の間にある境界に一致します。

複数のテキストを含む string 配列を作成します。テキストの先頭でなく、末尾でもない文字に一致するパターンを作成します。

txts = ["This text is first""Here is the second"“现在的re are three"];pat = ~textBoundary + lettersPattern + ~textBoundary;

パターンを抽出します。

lastWords = extract(txts,pat)
lastWords =3x4 string"his" "text" "is" "firs" "ere" "is" "the" "secon" "ow" "there" "are" "thre"

入力引数

すべて折りたたむ

境界タイプ。'start''end'または'either'として指定します。

データ型:char|string

出力引数

すべて折りたたむ

パターン式。patternオブジェクトとして返されます。

バージョン履歴

R2020b で導入