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" 
    "Now there 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" 
    "Now there are three"];
pat = 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" 
    "Now there 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オブジェクトとして返されます。

拡張機能

スレッドベースの環境
MATLAB® の backgroundPool を使用してバックグラウンドでコードを実行するか、Parallel Computing Toolbox™ の ThreadPool を使用してコードを高速化します。

バージョン履歴

R2020b で導入