P code
Format
P(pattern) [ { ; | / } (pattern) ] ...
The P code extracts data whose values match one or more patterns. If the data does not match any of the patterns, an empty string is returned.
pattern can contain one or more of the following codes:
- nN
- An integer followed by the letter N, which tests for n numeric characters.
- nA
- An integer followed by the letter A, which tests for n alphabetic characters.
- nX
- An integer followed by the letter X, which tests for n alphanumeric characters.
- nnnn
- A literal string, which tests for that literal string.
If n is 0, any number of numeric, alphabetic, or alphanumeric characters matches. If either the data or the match pattern is the null value, null is returned.
Separate multiple ranges by a semicolon ( ; ) or a slash ( / ).
Parentheses must enclose each pattern to be matched. 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.