Skip to main content

Complex Pattern Matching

You could use the following complex pattern to validate last names such as the one in the previous example (O'Reilly-McMahon 3rd), while rejecting the other strings that .ANP accepts. Note that this example uses pattern matching with the indirection operator @ to clarify the pattern components. Indirection is beyond the scope of this tutorial.

SAMPLES>set lastname = ".1(1""O'"",1""Mc"")1U.L"

SAMPLES>set hyphenname = ".1(1""-"".1(1""O'"",1""Mc"")1U.L)"

SAMPLES>set title = ".1(1"" ""1(1""Sr"",1""Jr"",1""3rd"",1""4th""))"

SAMPLES>set complete = lastname _ hyphenname _ title

SAMPLES>if last1?@complete {write "valid"}
SAMPLES>if last2?@complete {write "valid"}


FeedbackOpens in a new tab