PATTERN
Searches within a string for a set of characters that match a specified pattern. If it finds a match, Enrichment returns the characters.
Syntax
PATTERN(string,pattern,[start])
Arguments
Argument | Description | Default |
---|---|---|
string | The string within which to search. | None |
pattern | A string of specification characters that identifies the pattern to seek. Valid specification characters are: ' ' —A single blank. '@'—A single alphabetic character (A to Z or a to z). '#'—A single numeric character (0 to 9). '&'—A single alphabetic or numeric character. '+'—A single blank or numeric character. '*'—Any single character. Enrichment assumes all other characters in pattern are constants that must match exactly in case and position. Blanks at either end of pattern are not ignored at either end of string. That is, such blanks must be present in string if you specified them in pattern. Enrichment ignores wild card characters (that is, *) at either end of pattern. |
None |
[start] | Starting position (greater than 0) in string at which to begin the search. | 1 |
Results
Result | Description | |
---|---|---|
Return | A substring of string that matches pattern. | |
%%RC | One of the following: | |
-1 | start is less than or equal to 0 | |
0 | No error | |
1 | pattern has no contents or contains only wild card characters | |
2 | start is larger than string. | |
3 | pattern not found in string. | |
%%RM | A null string (''). | |
%%RV | The character position in string at which pattern begins, or 0 if Enrichment does not find pattern. |
Examples
Function Call | Return | %%RC | %%RV |
---|---|---|---|
PATTERN('Lexington, KY 40513-2341-12 USA','#####',1) | '40513' | 0 | 15 |
PATTERN('Lexington, KY 40513-2341-12 USA','@@ #####',1) | 'KY 40513 | 0 | 12 |
PATTERN('Lexington, KY 40513-2341-12 USA','##-##',1) | '13-23' | 0 | 18 |
PATTERN('Lexington, KY 40513-2341-12 USA','##-##',21) | '41-12' | 0 | 23 |
PATTERN('Lexington, KY 40513-2341-12 USA','##-##',40) | '' | 2 | 0 |
PATTERN('Lexington, KY 40513-2341-12 USA','++*++',1) | ' 4051' | 0 | 14 |
PATTERN('Lexington, KY 40513-2341-12 USA','&&*&&',1) | 'Lexin' | 0 | 1 |
PATTERN('Lexington, KY 40513-2341-12 USA','&&-&&',1) | '13-23 | 0 | 18 |
PATTERN('Lexington, KY 40513-2341-12 USA','## USA',1) | '12 USA' | 0 | 26 |
PATTERN('Lexington, KY 40513-2341-12 USA','&&USA',1) | '' | 3 | 0 |
PATTERN('Lexington, KY 40513-2341-12 USA','*ex*',1) | 'ex' | 0 | 2 |