docs.intersystems.com
ObjectScript Tutorial
Pattern Matching Examples
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

Here are some examples of good (and bad) patterns to illustrate how the pattern match operator works:

SAMPLES>set ssn = "012-34-5678"

SAMPLES>if ssn?3N1"-"2N1"-"4N write "valid"
valid
SAMPLES>set ht1 = "6 feet 2 inches", ht2 = "5' 10"""

SAMPLES>if ht1?1N1(1" feet",1"'")1" "1.2N1(1" inches",1"""") {write "valid"}
valid
SAMPLES>if ht2?1N1(1" feet",1"'")1" "1.2N1(1" inches",1"""") {write "valid"}
valid
SAMPLES>set last1 = "O'Reilly-McMahon 3rd", last2 = "/////32351abcde"

SAMPLES>if last1?.ANP {write "valid"} ; good name
valid
SAMPLES>if last2?.ANP {write "valid"} ; bad name
valid
SAMPLES>set c="InterSystems" if c?1"Inter".E {write "valid"}
valid
SAMPLES>


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA