Recipe 10.23. Using Patterns to Match Broad Content Types


Problem

You want to classify values into broad categories.

Solution

Use a pattern that is similarly broad.

Discussion

If you need to know whether values are empty or nonempty, or consist only of certain types of characters, the patterns listed in the following table may suffice:

PatternType of value the pattern matches
/^$/ Empty value
/./ Nonempty value
/^\s*$/ Whitespace, possibly empty
/^\s+$/ Nonempty whitespace
/\S/ Nonempty, and not just whitespace
/^\d+$/ Digits only, nonempty
/^[a-z]+$/i Alphabetic characters only (case-insensitive), nonempty
/^\w+$/ Alphanumeric or underscore characters only, nonempty





MySQL Cookbook
MySQL Cookbook
ISBN: 059652708X
EAN: 2147483647
Year: 2004
Pages: 375
Authors: Paul DuBois

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net