newStr = extract(str,pat)
returns any substrings in str that match the pattern specified by
pat.
If str is a string array or a cell array of character vectors, then
the function extracts substrings from each element of str. If
pat is an array, then the function matches against multiple
patterns.
The digitsPattern pattern matches street numbers, apartment numbers, and ZIP codes. To match only ZIP codes, create a pattern that matches a sequence of digits at the end of an address.
pat = digitsPattern + textBoundary
pat = pattern
Matching:
digitsPattern + textBoundary
Extract the ZIP codes.
newStr = extract(str,pat)
newStr = 3x1 string
"02116"
"92530"
"02138"
For a list of functions that create pattern objects, see pattern.