テキスト項目(テキストエリア)に含まれる文字列から、特定のキーワードで囲まれた部分だけを抜き出すには、MID、FIND、LEN、TRIM などの関数を組み合わせた数式を使用します。
テキスト項目やテキストエリアに入力されたデータから、特定のキーワードで囲まれた部分を抜き出す数式の記述方法について説明します。この数式は、FIND関数、MID関数、LEN関数を組み合わせて「抽出の開始位置」と「文字数」を特定します。
・実装例:
テキストエリア項目 (Field1__c) に以下の文言が入力されており、キーワードの【1】と【2】の間の文字列(IT)のみを抽出したい場合
項目 (Field1__c) に入力されている文字列:「【1】IT【2】Salesforce」
・数式サンプル:
TRIM(
MID(
Field1__c,
FIND("【1】", Field1__c) + LEN("【1】"),
FIND("【2】", Field1__c) - (FIND("【1】", Field1__c) + LEN("【1】"))
)
)
・使用する関数の役割:
| 関数 | 役割 | 上記数式における具体的な役割 |
| FIND | テキスト文字列中での指定した文字列の位置を数値で返します。 | キーワード(【1】、【2】)が、全体の何文字目にあるかを数字で返します。 |
| LEN | 指定したテキスト文字列の文字数を返します。 | キーワード自体の文字数をカウントし、抽出開始位置を調整します。 |
| MID | テキスト文字列中の途中で指定した開始位置から、指定した数の文字を返します。 | 特定の開始位置から、指定した文字数分だけを抜き出します。 |
| TRIM | テキスト文字列の先頭と末尾から、スペースとタブを削除します。 | 抽出した文字列の前後にある不要なスペース(空白)を削除します。 |
・結果
上記の数式により、【1】と【2】の間の文字列「IT」のみが抽出されます。
考慮事項:
005232627

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.