Database Reference
In-Depth Information
Matching Character Classes
There are
matches that you'll find yourself using frequently—digits, or all
alphabetical characters, or all alphanumerical characters, and so on. To make
working with these easier, you may use predefined character sets known as
character classes . Table 9.2 lists the character classes and what they mean.
Table 9.2 Character Classes
Class
Description
[:alnum:]
Any letter or digit, (same as [a-zA-Z0-9] )
[:alpha:]
Any letter (same as [a-zA-Z] )
[:blank:]
Space or tab (same as [\\t ] )
[:cntrl:]
ASCII control characters (ASCII 0 through 31 and 127 )
[:digit:]
Any digit (same as [0-9] )
[:graph:]
Same as [:print:] but excludes space
[:lower:]
Any lowercase letter (same as [a-z] )
[:print:]
Any printable character
[:punct:]
Any character that is neither in [:alnum:] nor [:cntrl:]
[:space:]
Any whitespace character including the space (same as
[\\f\\n\\r\\t\\v ] )
[:upper:]
Any uppercase letter (same as [A-Z] )
[:xdigit:]
Any hexadeci al digit (sa
e as [a-fA-F0-9] )
Matching Multiple Instances
All the
regular expressions used thus far attempt to match a single occur-
rence. If there is a match, the row is retrieved, and if not, nothing is retrieved.
But sometimes you require greater control over the number of matches. For
example, you might want to locate all numbers regardless of how many digits
the number contains, or you might want to locate a word but also be able to
accommodate a trailing s if one exists, and so on.
This can be accomplished using the regular expressions repetition metacharac-
ters, listed in Table 9.3.
 
 
 
 
Search WWH ::




Custom Search