P Correlative

Pattern Matching. The P correlative extracts data whose values match the specified pattern. If the data does not match the specified pattern, a null value is returned.

Format

P (pattern) [; (pattern)…]

Parameter(s)

pattern

nA

Integer followed by the letter A, which tests for n alphabetic characters.

nN

Integer followed by the letter N, which tests for n numeric characters.

nX

Integer followed by the letter X, which tests for n alphanumeric characters.

'xxxx'

Literal string which must match the same literal string in the data. A literal string must be enclosed in single quotes. Single-character delimiters such as hyphens or slashes need not be enclosed in quotes.

Description

If n is 0, any number of numeric, alphabetic, or alphanumeric characters match.

Each pattern to be matched must be enclosed in parentheses.

For example, if the user wanted only Social Security numbers returned, P(3N-2N-4N) would test for strings of exactly three numbers, then a hyphen, then exactly two numbers, then a hyphen, then exactly four numbers.

Using the P Correlative

If pattern is...

then output is...

'617'-3N-4N

Any phone number with a 617 area code.

2N/2N/2N

Any field that resembles a date in external format.

2N:2N:2N

Any field that resembles the time in external format.

5A5X

A string comprised of five alphabetic characters followed by five alphanumeric characters. (For example, a Customer-ID might be made up of the first letter of the customer’s first name, the first four letters of the last name, and the first five characters of the street address.)

'10'3N

Any five-digit order-ID that begins with 10.

See Also

Correlatives and Conversions Reference