SPUG: Perl accessable ctype.h macros
Yitzchak Scott-Thoennes
sthoenna at efn.org
Wed Oct 1 16:45:16 CDT 2003
On Wed, Oct 01, 2003 at 10:31:47AM -0700, Colin Meyer <cmeyer at helvella.org> wrote:
> On Wed, Oct 01, 2003 at 10:14:34AM -0700, Michael R. Wolf wrote:
> >
> > Is there a Perl-accessible interface to ctype.h and it's family of is*
> > macros (i.e. isalpha, isalphanum, isprintable, iswhitespace...)?
>
> See 'perldoc POSIX'.
You can [[:class:]] in regular expressions. perldoc perlre:
The POSIX character class syntax
[:class:]
is also available. The available classes and their backslash equivalents
(if available) are as follows:
alpha
alnum
ascii
blank [1]
cntrl
digit \d
graph
lower
print
punct
space \s [2]
upper
word \w [3]
xdigit
[1] A GNU extension equivalent to "[ \t]", `all horizontal whitespace'.
[2] Not exactly equivalent to "\s" since the "[[:space:]]" includes also
the (very rare) `vertical tabulator', "\ck", chr(11).
[3] A Perl extension, see above.
For example use "[:upper:]" to match all the uppercase characters. Note
that the "[]" are part of the "[::]" construct, not part of the whole
character class. For example:
[01[:alpha:]%]
matches zero, one, any alphabetic character, and the percentage sign.
More information about the spug-list
mailing list