MTRIM - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
Language
English
Product name
Connect CDC (SQData)
Title
Connect CDC (SQData) Apply engine
Copyright
2024
First publish date
2000
ft:lastEdition
2024-07-30
ft:lastPublication
2024-07-30T20:19:56.898694

The MTRIM function removes characters from a data string based on a string of exclusion characters. It also provides flexibility regarding the method of comparison by specifying either the ANY or MATCH parameter. Working from left to right, if a match is found between the data string and the exclusion character string, the MTRIM function removes the characters.

Note: For single character matches, ANY and MATCH will return the same results.

A common use of MTRIM is to remove spaces from a string, dashes from phone number or common date punctuation from a formatted date or timestamp.

Category

String

Syntax
MTRIM(data_string, exclude_character_string, ''ANY' | 'MATCH')
Parameters and Descriptions
Parameter Description
data_string

The data string in character format. The data string can be a field from a source datastore, a variable, a constant or the result of another Function.

exclusion_character_string One (1) or more characters that are to be removed from the left hand side of the data string. Exclusion characters may be a field of a source datastore, a literal value or the output of another Function.
ANY | MATCH

Denotes the type of matching from the left side of a source data string based on the contents of the exclusion character string. These parameters must be enclosed in single quotes.

ANY Indicates that partial matches to the exclusion sting are allowed. ANY is most useful when the exclusion string is more than one character. As MTRIM scans the data string from left to right, the current character will be removed if it appears anywhere in the exclusion string. Thus, the exclusion string should be thought of as a list of characters which have no order. MTRIM will stop scanning when reaches the end of the data string.
MATCH

Indicates that an exact match to the exclusion string must be made. MTRIM scans the data string until it finds the first character of the exclusion string in the data string, then checks the next letter of the data string to see if it matches the next letter of the exclusion string and so on, to the end of the exclusion string. If a full match is found, it is removed from the data string and MTRIM continues scanning the data string to see if there is another exact match to remove. All contiguous instances of the exclusion string will be removed from the data string.

Example 1

The INPUT_STRING contains the value XXYYAAABB.

OUTPUT_STRING = MTRIM(INPUT_STRING, 'YA', 'ANY' )

Returns the value XXBB and maps the result to the target field.

Example 2

The INPUT_STRING contains the value XXYYAAABB.
OUTPUT_STRING = MTRIM(INPUT_STRING, 'YA', 'MATCH' )

Returns the value XXYAABB and maps the result to the target field.

Example 3

The INPUT_STRING contains the a Timestamp value 2023-05-22-16:36:15.123456.
OUTPUT_STRING = MTRIM(INPUT_STRING, '-:.', 'ANY' )

Returns the value 20230522163615123456 and maps the result to the target field.