textBoundary
説明
例
テキストの境界に一致
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"
入力引数
type
— 境界タイプ
'either'
(既定値) | 'start'
| 'end'
境界タイプ。'start'
、'end'
または 'either'
として指定します。
データ型: char
| string
バージョン履歴
R2020b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)