TRIMV: Removing Characters From a String

How to:

The TRIMV function removes a pattern from a string and is similar to TRIM. However, both the source string and the pattern of characters to remove can have an AnV format.

Note: The TRIMV function 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_format)

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 AnV or An

Is the string to truncate. If it is a field of type AnV, its length is taken from the length-in-bytes of the field. If the upper_limit is smaller than the length, the source_string is truncated to the upper_limit.

upper_limit

Integer

Is the limit value for the length of the source_string.

pattern

Alphanumeric of type AnV or An

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

pattern_limit

Integer

Is the limit for the length of the pattern.

output_format

Alphanumeric type AnV or An

If the format is AnV, the length is set equal 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