Kernel 8.0 APIs Banner
Office of Information and Technology (OIT) Banner
[skip navigation]

$$TRIM^XLFSTR(): Trim String

Reference Type: Supported, Category: String Functions, ICR#: 10104

Description

The $$TRIM^XLFSTR extrinsic function trims spaces or other specified characters from the left, right, or both ends of an input string.

Format

  $$TRIM^XLFSTR(s[,f][,c])

Input Parameters

s:

(required) Character string.

f:

(optional) This flag can have the following value:

  • LR (default)—Trim characters from both ends of the string.

  • L—Trim characters from the left/beginning of the string.

  • R—Trim characters from the right/end of the string.
c: (optional) Set this parameter to the character to trim from the input string. This parameter defaults to a space.

Output

returns: Returns the trimmed string.

Examples

Example 1

In this example, we are trimming the spaces from both the left and right end of the string (the brackets are added to more clearly display the trimmed string):

>S X="["_$$TRIM^XLFSTR("  A B C  ")_"]"

>W X
[A B C]

The second input parameter defaults to LR and the third input parameter defaults to spaces.

Example 2

In this example, we are trimming the slashes from both the left and right end of the string (the brackets are added to more clearly display the trimmed string):

>S X="["_$$TRIM^XLFSTR("//A B C//",,"/")_"]"

>W X
[A B C]

The second input parameter defaults to LR.

Example 3

In this example, we are trimming the slashes from the left end of the string (the brackets are added to more clearly display the trimmed string):

>S X="["_$$TRIM^XLFSTR("//A B C//","L","/")_"]"

>W X
[A B C//]

Example 4

In this example, we are trimming the slashes from the right end of the string (the brackets are added to more clearly display the trimmed string):

>S X="["_$$TRIM^XLFSTR("//A B C//","r","/")_"]"

>W X
[//A B C]