maskedPattern

Pattern that matches like another pattern but displays as chosen text.

Category: Language Fundamentals > Data Types

Syntax

pat = maskedPattern(p, mask)

Matches the same text as p, and shows mask when the pattern is displayed.

Description

Large patterns built from many pieces can be hard to read when displayed. Wrapping a piece in maskedPattern gives it a short label, such as N for a number, so that the whole pattern prints in a readable form. Matching is not affected by the mask.

Input arguments

p
The pattern or text that does the matching.
mask
Text used to represent the pattern in its display.

Output arguments

pat
A pattern object.

Example

Labeling part of a pattern

p = 'a' + maskedPattern(digitsPattern, 'N')
extract('a12 b3', p)
Output
p = pattern
  Matching:

    "a" + N
ans = "a12"

See also

pattern namedPattern digitsPattern extract