by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)


A Swiss Army Knife

The pattern facet (like regular expressions in general), is like a Swiss Army knife when constraining simple datatypes. It can be used for many functions and can compensate for many of the limitations of the other facets; it's often used to define user datatypes in various formats, such as ISBN numbers, telephone numbers, or custom date formats. However, just like real Swiss Army knives, there are limits to its usefulness.

Cutting a tree with a Swiss Army knife is time-consuming, tiring, and dangerous. Writing regular expressions can also become time-consuming, tiring, and dangerous as the number of combinations grows. You should try to keep them as simple as possible.

[Tip]Tip

A Swiss Army knife can't change lead into gold, and no facet can change the primary type of a simple datatype. A string datatype restricted to match a custom date format will still retain the properties of a string and will never acquire the facets of a datetime datatype. This means there's no effective way to express localized date formats.


This text is released under the Free Software Foundation GFDL.