TRIMV: Removing Characters From a String

How to:

The TRIMV function removes leading and/or trailing occurrences of a pattern within a character string. TRIMV is similar to TRIM. However, TRIMV allows the source string and the pattern to be removed to have AnV format.

TRIMV is useful for converting an An field to an AnV field (with the length in bytes containing the actual length of the data up to the last non-blank character).


Top of page

x
Syntax: How to Remove Characters From a String
TRIMV(trim_where, source_string, upper_limit, pattern, pattern_limit,  output)

where:

trim_where

Alphanumeric

Is one of the following, which indicates where to remove the pattern:

'L' removes leading occurrences.

'T' removes trailing occurrences.

'B' removes both leading and trailing occurrences.

source_string

Alphanumeric of type An or AnV

Is the source string to be trimmed. If it is a field of type AnV, its length is taken from the length in bytes stored in the field. If upper_limit is smaller than the actual length, the source string is truncated to this upper limit.

upper_limit

Integer

Is the upper limit for the length of the source string.

pattern

Alphanumeric of type An or AnV

Is the pattern to remove. If it is a field of type AnV, its length is taken from the length in bytes stored in the field. If pattern_limit is smaller than the actual length, the pattern is truncated to this limit.

plength_limit

Integer

Is the limit for the length of the pattern.

output

Alphanumeric of type An or AnV

If the output format is AnV, the length is set to the number of characters left after trimming.



Example: Creating an AnV Field by Removing Trailing Blanks

TRIMV removes trailing blanks from TITLE and stores the result in a column with the format A39V:

TRIMV('T', TITLE, 39, ' ', 1, 'A39V')

iWay Software