| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
13.2.4 POSIX character classes
A POSIX character class is a special metasequence
of the form [:...:] that can be used only
inside a bracketed expression. The POSIX classes
supported are
[:alnum:]letters and digits[:alpha:]letters[:algor:]the lettersc,h,aandd[:ascii:]7-bit ascii characters[:blank:]widthful whitespace, ie, space and tab[:cntrl:]``control'' characters, viz, those with code<32[:digit:]digits, same as\d[:graph:]characters that use ink[:lower:]lower-case letters[:print:]ink-users plus widthful whitespace[:space:]whitespace, same as\s[:upper:]upper-case letters[:word:]letters, digits, and underscore, same as\w[:xdigit:]hex digits
For example, the regexp "[[:alpha:]_]"
matches a letter or underscore.
(pregexp-match "[[:alpha:]_]" "--x--") ⇒ ("x")
(pregexp-match "[[:alpha:]_]" "--_--") ⇒ ("_")
(pregexp-match "[[:alpha:]_]" "--:--") ⇒ #f
The POSIX class notation is valid only inside a
bracketed expression. For instance, [:alpha:],
when not inside a bracketed expression, will not
be read as the letter class.
Rather it is (from previous principles) the character
class containing the characters :, a, l,
p, h.
(pregexp-match "[[:alpha:]]" "--a--") ⇒ ("a")
(pregexp-match "[[:alpha:]]" "--_--") ⇒ #f
By placing a caret (^) immediately after
[:, you get the inversion of that POSIX
character class. Thus, [:^alpha]
is the class containing all characters
except the letters.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 23, 2011 using texi2html 5.0.
