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

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.213.27