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 nine (9) in the mask, EDIT copies the corresponding character from the source field 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.

Note:


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 source_string must be at least as large as the number of 9's in the mask.

mask

Alphanumeric

Is a string of mask characters enclosed in single quotation marks. The length of the mask, excluding characters other than 9 and $, determines the length of the output field.



Example: Extracting Characters

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