Learn how to extract specific strings enclosed by keywords in text fields using a combination of MID, FIND, LEN, and TRIM functions in formulas.
This section explains how to create a formula to extract a specific string enclosed by keywords from data entered in a Text or Text Area field. The formula uses a combination of the FIND, MID, and LEN functions to identify the "starting position" and the "number of characters" for extraction.
・Implementation Example:
To extract only the string "IT" between the keywords "【1】" and "【2】" from the following text in a Text Area field (Field1__c)
Field value: "【1】IT【2】Salesforce"
・Formula Sample:
TRIM( MID( Field1__c, FIND("【1】", Field1__c) + LEN("【1】"), FIND("【2】", Field1__c) - (FIND("【1】", Field1__c) + LEN("【1】")) )・Role of Each Function:
| Function | General Role | Specific Role in the Above Formula |
| FIND | Returns the position of a specific string within a text string as a number. | Identifies the numerical character positions of the keywords "【1】" and "【2】". |
| LEN | Returns the number of characters in a text string. | Counts the length of the keyword itself to correctly offset the starting position. |
| MID | Returns a specific number of characters from a text string starting at a specified position. | Extracts only the target characters based on the identified start point and length. |
| TRIM | Removes spaces and tabs from the beginning and end of a text string. | Ensures any unnecessary whitespace around the extracted "IT" is removed. |
・Result:
The formula above successfully extracts the string "IT" located between "【1】" and "【2】".
・Considerations:
This formula assumes that each keyword appears only once and that "【1】" always precedes "【2】".
If these conditions are not met (e.g., the order of keywords is reversed), the formula may not return the intended result.
This is a general configuration example. Please adjust the logic according to your specific business requirements.
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.