PATTERNS: Returning a Pattern That Represents the Structure of the Input String

How to:

PATTERNS returns a string that represents the structure of the input argument. The returned pattern includes the following characters:

Note that special characters (for example, +-/=%) are returned exactly as they were in the input string.

The output is returned as variable length alphanumeric.

Syntax: How to Return a String That Represents the Pattern Profile of the Input Argument

PATTERNS(string)

where:

string

Alphanumeric

Is a string whose pattern will be returned.

Example: Returning a Pattern Representing an Input String

The following request returns patterns that represent customer addresses.

DEFINE FILE WFLITE
Address_Pattern/A40V = PATTERNS(ADDRESS_LINE_1);
END
 
TABLE FILE WFLITE
PRINT FST.ADDRESS_LINE_1 OVER
Address_Pattern
BY ADDRESS_LINE_1 NOPRINT SKIP-LINE
WHERE COUNTRY_NAME EQ 'United States'
WHERE CITY_NAME EQ 'Houston' OR 'Indianapolis' OR 'Chapel Hill' OR 'Bronx'
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

The partial output is shown in the following image. Note that the special characters (#-,) in an address are represented in the pattern as is.