INCLUDE( ) function
Returns a string that includes only the specified characters.
Syntax
INCLUDE(string, characters_to_include)
Parameters
Name | Type | Description |
---|---|---|
string | character | The value to restrict to included characters. |
characters_to_include | character |
The list of characters to include. If you specify double quotation marks in characters_to_include, you must enclose the list of characters in single quotation marks. For example: '"-/' Note If a character you specify to include does not appear in string, it is not included in the return value. |
Output
Character.
Examples
Basic examples
Returns "123", which is the input string with only numbers included:
INCLUDE("123 Main St.", "0123456789")
Returns "1231234", which is the input string with only numbers included:
INCLUDE("123-123-4", "1243")
Returns "" (nothing), because the input string does not contain "D":
INCLUDE("ABC", "D")
Remarks
How it works
The INCLUDE( ) function compares each character in string with the characters listed in characters_to_include. If a match occurs, the character is included in the output string.
No matching characters
If there are no matches between string and characters_to_include the output of the function is blank.
Case sensitivity
The INCLUDE( ) function is case-sensitive. If you specify "ID" in characters_to_include, these characters are not included in "id#94022". If there is a chance the case may be mixed, use the UPPER( ) function to convert string to uppercase.
For example:
INCLUDE(UPPER("id#94022"), "ID0123456789")
Usage tip
Use INCLUDE( ) if the set of characters you want to include is small, and the set you want to exclude is large.
Related functions
The INCLUDE( ) function is the opposite of the EXCLUDE( ) function.