PARSE() |
|
|
The PARSE() function matches a string against a pattern, inserting a delimiter between each pattern element.
Format
PARSE(string, pattern, delimiter)
where
The PARSE() function matches string against pattern and returns a copy of string with the delimiter character inserted between each pattern element. If the string does not completely match the pattern, a null string is returned.
The pattern string consists of one or more concatenated items from the following list.
The values n and m are integers with any number of digits. m must be greater than or equal to n.
The 0A, nA, 0N, nN and "string" patterns may be preceded by a tilde (~) to invert the match condition. For example, ~4N matches four non-numeric characters such as ABCD (not a string which is not four numeric characters such as 12C4).
A null string matches patterns ..., 0A, 0X, 0N, their inverses (~0A, etc) and "".
The 0X and n-mX patterns match against as few characters as necessary before control passes to the next pattern. For example, the string ABC123DEF matched against the pattern 0X2N0X matches the pattern components as ABC, 12 and 3DEF.
The 0N, n-mN, 0A, and n-mA patterns match against as many characters as possible. For example, the string ABC123DEF matched against the pattern 0X2-3N0X matches the pattern components as ABC, 123 and DEF.
The pattern string may contain alternative templates separated by value marks. The PARSE() function tries each template in turn until one is a successful match against string. If a match is found, the INMAT() function can be used to retrieve the value position within the pattern that matched.
The delimiter argument determines the character to be inserted between the portions of string that match each part of the pattern.
The PARSE() function returns a null string if no component of pattern matches string.
Example
TEL.NO = "01604-709200" DISPLAY PARSE(TEL.NO, "0N'-'0N", "|")
This program fragment displays 01604|-|709200
See also: |