myPatterns tutorial


myPatterns is a flexible library for pattern matching in Java and JavaScript programs.

Pattern matching is a well-known programming mechanism for recognizing data having a particular shape (or "matching" a particular "pattern"), and at the same time binding some variables occurring in the pattern to some sub-structures of those instances.

The standard matching implementations included in Java is limited to pattern matching of strings using regular expressions. Regexps are a very powerful matching notation, implemented in Java by the standard library java.util.regex.

MyPatterns implements nevertheless a much more general form of pattern matching:

Indeed, text matching is extremely useful when isolating substrings of "flat" strings, but cannot cope with data containing structures nested to an arbitrary level. Such "recursively" structured data are much better handled by the kind of matching that myPatterns implements.


Next: Predefined notation