EDIT: Extracting or Adding Characters

How to:

The EDIT function extracts characters from the source string and adds characters to the output string, according to the mask. It can extract a substring from different parts of the source string. It can also insert characters from the source string into an output string. For example, it can extract the first two characters and the last two characters of a string to form a single output string.

EDIT compares the characters in a mask to the characters in a source_string. When it encounters a 9 in the mask, EDIT copies the corresponding character from the source string to the output string. When it encounters a dollar sign $ in the mask, EDIT ignores the corresponding character in the source string. When it encounters any other character in the mask, EDIT copies that character to the corresponding position in the output string. This process ends when the mask is exhausted.


Top of page

x
Syntax: How to Extract or Add Characters
EDIT(source_string, 'mask')

where:

source_string

Alphanumeric

Is a character string from which to pick characters. Each 9 in the mask represents one digit so the size of the source_string must be at least as large as the number of 9's that appear in the mask.

mask

Alphanumeric

Is a string of mask characters.

The length of the mask without characters $ determines the length of the output string.

Note:



Example: Extracting Characters From a Column

EDIT extracts the first initials from the FNAME column.

EDIT(FNAME, '9$$$$$$$$$')

For GREGORY, the result is G.

For STEVEN, the result is S.


iWay Software