Loading

Extracting Strings Between Keywords Using Formulas

Дата публикации: Aug 4, 2026
Описание

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:

FunctionGeneral RoleSpecific Role in the Above Formula
FINDReturns the position of a specific string within a text string as a number.Identifies the numerical character positions of the keywords "【1】" and "【2】".
LENReturns the number of characters in a text string.Counts the length of the keyword itself to correctly offset the starting position.
MIDReturns 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.
TRIMRemoves 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.

Дополнительные ресурсы

TRIM
FIND
MID
Scope of support for formulas

Номер статьи базы знаний

005232627

 
Загрузка
Salesforce Help | Article