php IHDR w Q )Ba pHYs sRGB gAMA a IDATxMk\U s&uo,mD )Xw+e?tw.oWp;QHZnw`gaiJ9̟灙a=nl[ ʨ G;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ y H@E7j 1j+OFRg}ܫ;@Ea~ j`u'o> j- $_q?qS XzG'ay
files >> /opt/lampp/share/man/man1/ |
files >> //opt/lampp/share/man/man1/perlrecharclass.1 |
.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PERLRECHARCLASS 1" .TH PERLRECHARCLASS 1 "2013-03-04" "perl v5.16.3" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" perlrecharclass \- Perl Regular Expression Character Classes .IX Xref "character class" .SH "DESCRIPTION" .IX Header "DESCRIPTION" The top level documentation about Perl regular expressions is found in perlre. .PP This manual page discusses the syntax and use of character classes in Perl regular expressions. .PP A character class is a way of denoting a set of characters in such a way that one character of the set is matched. It's important to remember that: matching a character class consumes exactly one character in the source string. (The source string is the string the regular expression is matched against.) .PP There are three types of character classes in Perl regular expressions: the dot, backslash sequences, and the form enclosed in square brackets. Keep in mind, though, that often the term \*(L"character class\*(R" is used to mean just the bracketed form. Certainly, most Perl documentation does that. .SS "The dot" .IX Subsection "The dot" The dot (or period), \f(CW\*(C`.\*(C'\fR is probably the most used, and certainly the most well-known character class. By default, a dot matches any character, except for the newline. That default can be changed to add matching the newline by using the \fIsingle line\fR modifier: either for the entire regular expression with the \f(CW\*(C`/s\*(C'\fR modifier, or locally with \f(CW\*(C`(?s)\*(C'\fR. (The experimental \f(CW\*(C`\eN\*(C'\fR backslash sequence, described below, matches any character except newline without regard to the \&\fIsingle line\fR modifier.) .PP Here are some examples: .PP .Vb 7 \& "a" =~ /./ # Match \& "." =~ /./ # Match \& "" =~ /./ # No match (dot has to match a character) \& "\en" =~ /./ # No match (dot does not match a newline) \& "\en" =~ /./s # Match (global \*(Aqsingle line\*(Aq modifier) \& "\en" =~ /(?s:.)/ # Match (local \*(Aqsingle line\*(Aq modifier) \& "ab" =~ /^.$/ # No match (dot matches one character) .Ve .SS "Backslash sequences" .IX Xref "\\w \\W \\s \\S \\d \\D \\p \\P \\N \\v \\V \\h \\H word whitespace" .IX Subsection "Backslash sequences" A backslash sequence is a sequence of characters, the first one of which is a backslash. Perl ascribes special meaning to many such sequences, and some of these are character classes. That is, they match a single character each, provided that the character belongs to the specific set of characters defined by the sequence. .PP Here's a list of the backslash sequences that are character classes. They are discussed in more detail below. (For the backslash sequences that aren't character classes, see perlrebackslash.) .PP .Vb 10 \& \ed Match a decimal digit character. \& \eD Match a non\-decimal\-digit character. \& \ew Match a "word" character. \& \eW Match a non\-"word" character. \& \es Match a whitespace character. \& \eS Match a non\-whitespace character. \& \eh Match a horizontal whitespace character. \& \eH Match a character that isn\*(Aqt horizontal whitespace. \& \ev Match a vertical whitespace character. \& \eV Match a character that isn\*(Aqt vertical whitespace. \& \eN Match a character that isn\*(Aqt a newline. Experimental. \& \epP, \ep{Prop} Match a character that has the given Unicode property. \& \ePP, \eP{Prop} Match a character that doesn\*(Aqt have the Unicode property .Ve .PP \fI\eN\fR .IX Subsection "N" .PP \&\f(CW\*(C`\eN\*(C'\fR is new in 5.12, and is experimental. It, like the dot, matches any character that is not a newline. The difference is that \f(CW\*(C`\eN\*(C'\fR is not influenced by the \fIsingle line\fR regular expression modifier (see \*(L"The dot\*(R" above). Note that the form \f(CW\*(C`\eN{...}\*(C'\fR may mean something completely different. When the \&\f(CW\*(C`{...}\*(C'\fR is a quantifier, it means to match a non-newline character that many times. For example, \f(CW\*(C`\eN{3}\*(C'\fR means to match 3 non-newlines; \f(CW\*(C`\eN{5,}\*(C'\fR means to match 5 or more non-newlines. But if \f(CW\*(C`{...}\*(C'\fR is not a legal quantifier, it is presumed to be a named character. See charnames for those. For example, none of \f(CW\*(C`\eN{COLON}\*(C'\fR, \f(CW\*(C`\eN{4F}\*(C'\fR, and \&\f(CW\*(C`\eN{F4}\*(C'\fR contain legal quantifiers, so Perl will try to find characters whose names are respectively \f(CW\*(C`COLON\*(C'\fR, \f(CW\*(C`4F\*(C'\fR, and \f(CW\*(C`F4\*(C'\fR. .PP \fIDigits\fR .IX Subsection "Digits" .PP \&\f(CW\*(C`\ed\*(C'\fR matches a single character considered to be a decimal \fIdigit\fR. If the \f(CW\*(C`/a\*(C'\fR regular expression modifier is in effect, it matches [0\-9]. Otherwise, it matches anything that is matched by \f(CW\*(C`\ep{Digit}\*(C'\fR, which includes [0\-9]. (An unlikely possible exception is that under locale matching rules, the current locale might not have [0\-9] matched by \f(CW\*(C`\ed\*(C'\fR, and/or might match other characters whose code point is less than 256. Such a locale definition would be in violation of the C language standard, but Perl doesn't currently assume anything in regard to this.) .PP What this means is that unless the \f(CW\*(C`/a\*(C'\fR modifier is in effect \f(CW\*(C`\ed\*(C'\fR not only matches the digits '0' \- '9', but also Arabic, Devanagari, and digits from other languages. This may cause some confusion, and some security issues. .PP Some digits that \f(CW\*(C`\ed\*(C'\fR matches look like some of the [0\-9] ones, but have different values. For example, \s-1BENGALI\s0 \s-1DIGIT\s0 \s-1FOUR\s0 (U+09EA) looks very much like an \s-1ASCII\s0 \s-1DIGIT\s0 \s-1EIGHT\s0 (U+0038). An application that is expecting only the \s-1ASCII\s0 digits might be misled, or if the match is \&\f(CW\*(C`\ed+\*(C'\fR, the matched string might contain a mixture of digits from different writing systems that look like they signify a number different than they actually do. \*(L"\fInum()\fR\*(R" in Unicode::UCD can be used to safely calculate the value, returning \f(CW\*(C`undef\*(C'\fR if the input string contains such a mixture. .PP What \f(CW\*(C`\ep{Digit}\*(C'\fR means (and hence \f(CW\*(C`\ed\*(C'\fR except under the \f(CW\*(C`/a\*(C'\fR modifier) is \f(CW\*(C`\ep{General_Category=Decimal_Number}\*(C'\fR, or synonymously, \&\f(CW\*(C`\ep{General_Category=Digit}\*(C'\fR. Starting with Unicode version 4.1, this is the same set of characters matched by \f(CW\*(C`\ep{Numeric_Type=Decimal}\*(C'\fR. But Unicode also has a different property with a similar name, \&\f(CW\*(C`\ep{Numeric_Type=Digit}\*(C'\fR, which matches a completely different set of characters. These characters are things such as \f(CW\*(C`CIRCLED DIGIT ONE\*(C'\fR or subscripts, or are from writing systems that lack all ten digits. .PP The design intent is for \f(CW\*(C`\ed\*(C'\fR to exactly match the set of characters that can safely be used with \*(L"normal\*(R" big-endian positional decimal syntax, where, for example 123 means one 'hundred', plus two 'tens', plus three 'ones'. This positional notation does not necessarily apply to characters that match the other type of \*(L"digit\*(R", \&\f(CW\*(C`\ep{Numeric_Type=Digit}\*(C'\fR, and so \f(CW\*(C`\ed\*(C'\fR doesn't match them. .PP The Tamil digits (U+0BE6 \- U+0BEF) can also legally be used in old-style Tamil numbers in which they would appear no more than one in a row, separated by characters that mean \*(L"times 10\*(R", \*(L"times 100\*(R", etc. (See <http://www.unicode.org/notes/tn21>.) .PP Any character not matched by \f(CW\*(C`\ed\*(C'\fR is matched by \f(CW\*(C`\eD\*(C'\fR. .PP \fIWord characters\fR .IX Subsection "Word characters" .PP A \f(CW\*(C`\ew\*(C'\fR matches a single alphanumeric character (an alphabetic character, or a decimal digit) or a connecting punctuation character, such as an underscore (\*(L"_\*(R"). It does not match a whole word. To match a whole word, use \f(CW\*(C`\ew+\*(C'\fR. This isn't the same thing as matching an English word, but in the \s-1ASCII\s0 range it is the same as a string of Perl-identifier characters. .ie n .IP "If the ""/a"" modifier is in effect ..." 4 .el .IP "If the \f(CW/a\fR modifier is in effect ..." 4 .IX Item "If the /a modifier is in effect ..." \&\f(CW\*(C`\ew\*(C'\fR matches the 63 characters [a\-zA\-Z0\-9_]. .IP "otherwise ..." 4 .IX Item "otherwise ..." .RS 4 .PD 0 .IP "For code points above 255 ..." 4 .IX Item "For code points above 255 ..." .PD \&\f(CW\*(C`\ew\*(C'\fR matches the same as \f(CW\*(C`\ep{Word}\*(C'\fR matches in this range. That is, it matches Thai letters, Greek letters, etc. This includes connector punctuation (like the underscore) which connect two words together, or diacritics, such as a \f(CW\*(C`COMBINING TILDE\*(C'\fR and the modifier letters, which are generally used to add auxiliary markings to letters. .IP "For code points below 256 ..." 4 .IX Item "For code points below 256 ..." .RS 4 .PD 0 .IP "if locale rules are in effect ..." 4 .IX Item "if locale rules are in effect ..." .PD \&\f(CW\*(C`\ew\*(C'\fR matches the platform's native underscore character plus whatever the locale considers to be alphanumeric. .IP "if Unicode rules are in effect or if on an \s-1EBCDIC\s0 platform ..." 4 .IX Item "if Unicode rules are in effect or if on an EBCDIC platform ..." \&\f(CW\*(C`\ew\*(C'\fR matches exactly what \f(CW\*(C`\ep{Word}\*(C'\fR matches. .IP "otherwise ..." 4 .IX Item "otherwise ..." \&\f(CW\*(C`\ew\*(C'\fR matches [a\-zA\-Z0\-9_]. .RE .RS 4 .RE .RE .RS 4 .RE .PP Which rules apply are determined as described in \*(L"Which character set modifier is in effect?\*(R" in perlre. .PP There are a number of security issues with the full Unicode list of word characters. See <http://unicode.org/reports/tr36>. .PP Also, for a somewhat finer-grained set of characters that are in programming language identifiers beyond the \s-1ASCII\s0 range, you may wish to instead use the more customized \*(L"Unicode Properties\*(R", \f(CW\*(C`\ep{ID_Start}\*(C'\fR, \&\f(CW\*(C`\ep{ID_Continue}\*(C'\fR, \f(CW\*(C`\ep{XID_Start}\*(C'\fR, and \f(CW\*(C`\ep{XID_Continue}\*(C'\fR. See <http://unicode.org/reports/tr31>. .PP Any character not matched by \f(CW\*(C`\ew\*(C'\fR is matched by \f(CW\*(C`\eW\*(C'\fR. .PP \fIWhitespace\fR .IX Subsection "Whitespace" .PP \&\f(CW\*(C`\es\*(C'\fR matches any single character considered whitespace. .ie n .IP "If the ""/a"" modifier is in effect ..." 4 .el .IP "If the \f(CW/a\fR modifier is in effect ..." 4 .IX Item "If the /a modifier is in effect ..." \&\f(CW\*(C`\es\*(C'\fR matches the 5 characters [\et\en\ef\er ]; that is, the horizontal tab, the newline, the form feed, the carriage return, and the space. (Note that it doesn't match the vertical tab, \f(CW\*(C`\ecK\*(C'\fR on \s-1ASCII\s0 platforms.) .IP "otherwise ..." 4 .IX Item "otherwise ..." .RS 4 .PD 0 .IP "For code points above 255 ..." 4 .IX Item "For code points above 255 ..." .PD \&\f(CW\*(C`\es\*(C'\fR matches exactly the code points above 255 shown with an \*(L"s\*(R" column in the table below. .IP "For code points below 256 ..." 4 .IX Item "For code points below 256 ..." .RS 4 .PD 0 .IP "if locale rules are in effect ..." 4 .IX Item "if locale rules are in effect ..." .PD \&\f(CW\*(C`\es\*(C'\fR matches whatever the locale considers to be whitespace. Note that this is likely to include the vertical space, unlike non-locale \f(CW\*(C`\es\*(C'\fR matching. .IP "if Unicode rules are in effect or if on an \s-1EBCDIC\s0 platform ..." 4 .IX Item "if Unicode rules are in effect or if on an EBCDIC platform ..." \&\f(CW\*(C`\es\*(C'\fR matches exactly the characters shown with an \*(L"s\*(R" column in the table below. .IP "otherwise ..." 4 .IX Item "otherwise ..." \&\f(CW\*(C`\es\*(C'\fR matches [\et\en\ef\er ]. Note that this list doesn't include the non-breaking space. .RE .RS 4 .RE .RE .RS 4 .RE .PP Which rules apply are determined as described in \*(L"Which character set modifier is in effect?\*(R" in perlre. .PP Any character not matched by \f(CW\*(C`\es\*(C'\fR is matched by \f(CW\*(C`\eS\*(C'\fR. .PP \&\f(CW\*(C`\eh\*(C'\fR matches any character considered horizontal whitespace; this includes the platform's space and tab characters and several others listed in the table below. \f(CW\*(C`\eH\*(C'\fR matches any character not considered horizontal whitespace. They use the platform's native character set, and do not consider any locale that may otherwise be in use. .PP \&\f(CW\*(C`\ev\*(C'\fR matches any character considered vertical whitespace; this includes the platform's carriage return and line feed characters (newline) plus several other characters, all listed in the table below. \&\f(CW\*(C`\eV\*(C'\fR matches any character not considered vertical whitespace. They use the platform's native character set, and do not consider any locale that may otherwise be in use. .PP \&\f(CW\*(C`\eR\*(C'\fR matches anything that can be considered a newline under Unicode rules. It's not a character class, as it can match a multi-character sequence. Therefore, it cannot be used inside a bracketed character class; use \f(CW\*(C`\ev\*(C'\fR instead (vertical whitespace). It uses the platform's native character set, and does not consider any locale that may otherwise be in use. Details are discussed in perlrebackslash. .PP Note that unlike \f(CW\*(C`\es\*(C'\fR (and \f(CW\*(C`\ed\*(C'\fR and \f(CW\*(C`\ew\*(C'\fR), \f(CW\*(C`\eh\*(C'\fR and \f(CW\*(C`\ev\*(C'\fR always match the same characters, without regard to other factors, such as the active locale or whether the source string is in \s-1UTF\-8\s0 format. .PP One might think that \f(CW\*(C`\es\*(C'\fR is equivalent to \f(CW\*(C`[\eh\ev]\*(C'\fR. This is not true. The difference is that the vertical tab (\f(CW"\ex0b"\fR) is not matched by \&\f(CW\*(C`\es\*(C'\fR; it is however considered vertical whitespace. .PP The following table is a complete listing of characters matched by \&\f(CW\*(C`\es\*(C'\fR, \f(CW\*(C`\eh\*(C'\fR and \f(CW\*(C`\ev\*(C'\fR as of Unicode 6.0. .PP The first column gives the Unicode code point of the character (in hex format), the second column gives the (Unicode) name. The third column indicates by which class(es) the character is matched (assuming no locale or \s-1EBCDIC\s0 code page is in effect that changes the \f(CW\*(C`\es\*(C'\fR matching). .PP .Vb 10 \& 0x0009 CHARACTER TABULATION h s \& 0x000a LINE FEED (LF) vs \& 0x000b LINE TABULATION v \& 0x000c FORM FEED (FF) vs \& 0x000d CARRIAGE RETURN (CR) vs \& 0x0020 SPACE h s \& 0x0085 NEXT LINE (NEL) vs [1] \& 0x00a0 NO\-BREAK SPACE h s [1] \& 0x1680 OGHAM SPACE MARK h s \& 0x180e MONGOLIAN VOWEL SEPARATOR h s \& 0x2000 EN QUAD h s \& 0x2001 EM QUAD h s \& 0x2002 EN SPACE h s \& 0x2003 EM SPACE h s \& 0x2004 THREE\-PER\-EM SPACE h s \& 0x2005 FOUR\-PER\-EM SPACE h s \& 0x2006 SIX\-PER\-EM SPACE h s \& 0x2007 FIGURE SPACE h s \& 0x2008 PUNCTUATION SPACE h s \& 0x2009 THIN SPACE h s \& 0x200a HAIR SPACE h s \& 0x2028 LINE SEPARATOR vs \& 0x2029 PARAGRAPH SEPARATOR vs \& 0x202f NARROW NO\-BREAK SPACE h s \& 0x205f MEDIUM MATHEMATICAL SPACE h s \& 0x3000 IDEOGRAPHIC SPACE h s .Ve .IP "[1]" 4 .IX Item "[1]" \&\s-1NEXT\s0 \s-1LINE\s0 and NO-BREAK \s-1SPACE\s0 may or may not match \f(CW\*(C`\es\*(C'\fR depending on the rules in effect. See the beginning of this section. .PP \fIUnicode Properties\fR .IX Subsection "Unicode Properties" .PP \&\f(CW\*(C`\epP\*(C'\fR and \f(CW\*(C`\ep{Prop}\*(C'\fR are character classes to match characters that fit given Unicode properties. One letter property names can be used in the \f(CW\*(C`\epP\*(C'\fR form, with the property name following the \f(CW\*(C`\ep\*(C'\fR, otherwise, braces are required. When using braces, there is a single form, which is just the property name enclosed in the braces, and a compound form which looks like \f(CW\*(C`\ep{name=value}\*(C'\fR, which means to match if the property \*(L"name\*(R" for the character has that particular \&\*(L"value\*(R". For instance, a match for a number can be written as \f(CW\*(C`/\epN/\*(C'\fR or as \&\f(CW\*(C`/\ep{Number}/\*(C'\fR, or as \f(CW\*(C`/\ep{Number=True}/\*(C'\fR. Lowercase letters are matched by the property \fILowercase_Letter\fR which has the short form \fILl\fR. They need the braces, so are written as \f(CW\*(C`/\ep{Ll}/\*(C'\fR or \&\f(CW\*(C`/\ep{Lowercase_Letter}/\*(C'\fR, or \f(CW\*(C`/\ep{General_Category=Lowercase_Letter}/\*(C'\fR (the underscores are optional). \&\f(CW\*(C`/\epLl/\*(C'\fR is valid, but means something different. It matches a two character string: a letter (Unicode property \f(CW\*(C`\epL\*(C'\fR), followed by a lowercase \f(CW\*(C`l\*(C'\fR. .PP If neither the \f(CW\*(C`/a\*(C'\fR modifier nor locale rules are in effect, the use of a Unicode property will force the regular expression into using Unicode rules. .PP Note that almost all properties are immune to case-insensitive matching. That is, adding a \f(CW\*(C`/i\*(C'\fR regular expression modifier does not change what they match. There are two sets that are affected. The first set is \&\f(CW\*(C`Uppercase_Letter\*(C'\fR, \&\f(CW\*(C`Lowercase_Letter\*(C'\fR, and \f(CW\*(C`Titlecase_Letter\*(C'\fR, all of which match \f(CW\*(C`Cased_Letter\*(C'\fR under \f(CW\*(C`/i\*(C'\fR matching. The second set is \&\f(CW\*(C`Uppercase\*(C'\fR, \&\f(CW\*(C`Lowercase\*(C'\fR, and \f(CW\*(C`Titlecase\*(C'\fR, all of which match \f(CW\*(C`Cased\*(C'\fR under \f(CW\*(C`/i\*(C'\fR matching. (The difference between these sets is that some things, such as Roman numerals, come in both upper and lower case, so they are \f(CW\*(C`Cased\*(C'\fR, but aren't considered to be letters, so they aren't \f(CW\*(C`Cased_Letter\*(C'\fRs. They're actually \f(CW\*(C`Letter_Number\*(C'\fRs.) This set also includes its subsets \f(CW\*(C`PosixUpper\*(C'\fR and \f(CW\*(C`PosixLower\*(C'\fR, both of which under \f(CW\*(C`/i\*(C'\fR match \f(CW\*(C`PosixAlpha\*(C'\fR. .PP For more details on Unicode properties, see \*(L"Unicode Character Properties\*(R" in perlunicode; for a complete list of possible properties, see \&\*(L"Properties accessible through \ep{} and \eP{}\*(R" in perluniprops, which notes all forms that have \f(CW\*(C`/i\*(C'\fR differences. It is also possible to define your own properties. This is discussed in \&\*(L"User-Defined Character Properties\*(R" in perlunicode. .PP Unicode properties are defined (surprise!) only on Unicode code points. A warning is raised and all matches fail on non-Unicode code points (those above the legal Unicode maximum of 0x10FFFF). This can be somewhat surprising, .PP .Vb 2 \& chr(0x110000) =~ \ep{ASCII_Hex_Digit=True} # Fails. \& chr(0x110000) =~ \ep{ASCII_Hex_Digit=False} # Also fails! .Ve .PP Even though these two matches might be thought of as complements, they are so only on Unicode code points. .PP Examples .IX Subsection "Examples" .PP .Vb 8 \& "a" =~ /\ew/ # Match, "a" is a \*(Aqword\*(Aq character. \& "7" =~ /\ew/ # Match, "7" is a \*(Aqword\*(Aq character as well. \& "a" =~ /\ed/ # No match, "a" isn\*(Aqt a digit. \& "7" =~ /\ed/ # Match, "7" is a digit. \& " " =~ /\es/ # Match, a space is whitespace. \& "a" =~ /\eD/ # Match, "a" is a non\-digit. \& "7" =~ /\eD/ # No match, "7" is not a non\-digit. \& " " =~ /\eS/ # No match, a space is not non\-whitespace. \& \& " " =~ /\eh/ # Match, space is horizontal whitespace. \& " " =~ /\ev/ # No match, space is not vertical whitespace. \& "\er" =~ /\ev/ # Match, a return is vertical whitespace. \& \& "a" =~ /\epL/ # Match, "a" is a letter. \& "a" =~ /\ep{Lu}/ # No match, /\ep{Lu}/ matches upper case letters. \& \& "\ex{0e0b}" =~ /\ep{Thai}/ # Match, \ex{0e0b} is the character \& # \*(AqTHAI CHARACTER SO SO\*(Aq, and that\*(Aqs in \& # Thai Unicode class. \& "a" =~ /\eP{Lao}/ # Match, as "a" is not a Laotian character. .Ve .PP It is worth emphasizing that \f(CW\*(C`\ed\*(C'\fR, \f(CW\*(C`\ew\*(C'\fR, etc, match single characters, not complete numbers or words. To match a number (that consists of digits), use \f(CW\*(C`\ed+\*(C'\fR; to match a word, use \f(CW\*(C`\ew+\*(C'\fR. But be aware of the security considerations in doing so, as mentioned above. .SS "Bracketed Character Classes" .IX Subsection "Bracketed Character Classes" The third form of character class you can use in Perl regular expressions is the bracketed character class. In its simplest form, it lists the characters that may be matched, surrounded by square brackets, like this: \f(CW\*(C`[aeiou]\*(C'\fR. This matches one of \f(CW\*(C`a\*(C'\fR, \f(CW\*(C`e\*(C'\fR, \f(CW\*(C`i\*(C'\fR, \f(CW\*(C`o\*(C'\fR or \f(CW\*(C`u\*(C'\fR. Like the other character classes, exactly one character is matched.* To match a longer string consisting of characters mentioned in the character class, follow the character class with a quantifier. For instance, \f(CW\*(C`[aeiou]+\*(C'\fR matches one or more lowercase English vowels. .PP Repeating a character in a character class has no effect; it's considered to be in the set only once. .PP Examples: .PP .Vb 5 \& "e" =~ /[aeiou]/ # Match, as "e" is listed in the class. \& "p" =~ /[aeiou]/ # No match, "p" is not listed in the class. \& "ae" =~ /^[aeiou]$/ # No match, a character class only matches \& # a single character. \& "ae" =~ /^[aeiou]+$/ # Match, due to the quantifier. \& \& \-\-\-\-\-\-\- .Ve .PP * There is an exception to a bracketed character class matching a single character only. When the class is to match caselessly under \f(CW\*(C`/i\*(C'\fR matching rules, and a character inside the class matches a multiple-character sequence caselessly under Unicode rules, the class (when not inverted) will also match that sequence. For example, Unicode says that the letter \f(CW\*(C`LATIN SMALL LETTER SHARP S\*(C'\fR should match the sequence \f(CW\*(C`ss\*(C'\fR under \f(CW\*(C`/i\*(C'\fR rules. Thus, .PP .Vb 2 \& \*(Aqss\*(Aq =~ /\eA\eN{LATIN SMALL LETTER SHARP S}\ez/i # Matches \& \*(Aqss\*(Aq =~ /\eA[aeioust\eN{LATIN SMALL LETTER SHARP S}]\ez/i # Matches .Ve .PP \fISpecial Characters Inside a Bracketed Character Class\fR .IX Subsection "Special Characters Inside a Bracketed Character Class" .PP Most characters that are meta characters in regular expressions (that is, characters that carry a special meaning like \f(CW\*(C`.\*(C'\fR, \f(CW\*(C`*\*(C'\fR, or \f(CW\*(C`(\*(C'\fR) lose their special meaning and can be used inside a character class without the need to escape them. For instance, \f(CW\*(C`[()]\*(C'\fR matches either an opening parenthesis, or a closing parenthesis, and the parens inside the character class don't group or capture. .PP Characters that may carry a special meaning inside a character class are: \&\f(CW\*(C`\e\*(C'\fR, \f(CW\*(C`^\*(C'\fR, \f(CW\*(C`\-\*(C'\fR, \f(CW\*(C`[\*(C'\fR and \f(CW\*(C`]\*(C'\fR, and are discussed below. They can be escaped with a backslash, although this is sometimes not needed, in which case the backslash may be omitted. .PP The sequence \f(CW\*(C`\eb\*(C'\fR is special inside a bracketed character class. While outside the character class, \f(CW\*(C`\eb\*(C'\fR is an assertion indicating a point that does not have either two word characters or two non-word characters on either side, inside a bracketed character class, \f(CW\*(C`\eb\*(C'\fR matches a backspace character. .PP The sequences \&\f(CW\*(C`\ea\*(C'\fR, \&\f(CW\*(C`\ec\*(C'\fR, \&\f(CW\*(C`\ee\*(C'\fR, \&\f(CW\*(C`\ef\*(C'\fR, \&\f(CW\*(C`\en\*(C'\fR, \&\f(CW\*(C`\eN{\f(CINAME\f(CW}\*(C'\fR, \&\f(CW\*(C`\eN{U+\f(CIhex char\f(CW}\*(C'\fR, \&\f(CW\*(C`\er\*(C'\fR, \&\f(CW\*(C`\et\*(C'\fR, and \&\f(CW\*(C`\ex\*(C'\fR are also special and have the same meanings as they do outside a bracketed character class. (However, inside a bracketed character class, if \f(CW\*(C`\eN{\f(CINAME\f(CW}\*(C'\fR expands to a sequence of characters, only the first one in the sequence is used, with a warning.) .PP Also, a backslash followed by two or three octal digits is considered an octal number. .PP A \f(CW\*(C`[\*(C'\fR is not special inside a character class, unless it's the start of a \&\s-1POSIX\s0 character class (see \*(L"\s-1POSIX\s0 Character Classes\*(R" below). It normally does not need escaping. .PP A \f(CW\*(C`]\*(C'\fR is normally either the end of a \s-1POSIX\s0 character class (see \&\*(L"\s-1POSIX\s0 Character Classes\*(R" below), or it signals the end of the bracketed character class. If you want to include a \f(CW\*(C`]\*(C'\fR in the set of characters, you must generally escape it. .PP However, if the \f(CW\*(C`]\*(C'\fR is the \fIfirst\fR (or the second if the first character is a caret) character of a bracketed character class, it does not denote the end of the class (as you cannot have an empty class) and is considered part of the set of characters that can be matched without escaping. .PP Examples: .PP .Vb 8 \& "+" =~ /[+?*]/ # Match, "+" in a character class is not special. \& "\ecH" =~ /[\eb]/ # Match, \eb inside in a character class \& # is equivalent to a backspace. \& "]" =~ /[][]/ # Match, as the character class contains. \& # both [ and ]. \& "[]" =~ /[[]]/ # Match, the pattern contains a character class \& # containing just ], and the character class is \& # followed by a ]. .Ve .PP \fICharacter Ranges\fR .IX Subsection "Character Ranges" .PP It is not uncommon to want to match a range of characters. Luckily, instead of listing all characters in the range, one may use the hyphen (\f(CW\*(C`\-\*(C'\fR). If inside a bracketed character class you have two characters separated by a hyphen, it's treated as if all characters between the two were in the class. For instance, \f(CW\*(C`[0\-9]\*(C'\fR matches any \s-1ASCII\s0 digit, and \f(CW\*(C`[a\-m]\*(C'\fR matches any lowercase letter from the first half of the \s-1ASCII\s0 alphabet. .PP Note that the two characters on either side of the hyphen are not necessarily both letters or both digits. Any character is possible, although not advisable. \f(CW\*(C`[\*(Aq\-?]\*(C'\fR contains a range of characters, but most people will not know which characters that means. Furthermore, such ranges may lead to portability problems if the code has to run on a platform that uses a different character set, such as \s-1EBCDIC\s0. .PP If a hyphen in a character class cannot syntactically be part of a range, for instance because it is the first or the last character of the character class, or if it immediately follows a range, the hyphen isn't special, and so is considered a character to be matched literally. If you want a hyphen in your set of characters to be matched and its position in the class is such that it could be considered part of a range, you must escape that hyphen with a backslash. .PP Examples: .PP .Vb 8 \& [a\-z] # Matches a character that is a lower case ASCII letter. \& [a\-fz] # Matches any letter between \*(Aqa\*(Aq and \*(Aqf\*(Aq (inclusive) or \& # the letter \*(Aqz\*(Aq. \& [\-z] # Matches either a hyphen (\*(Aq\-\*(Aq) or the letter \*(Aqz\*(Aq. \& [a\-f\-m] # Matches any letter between \*(Aqa\*(Aq and \*(Aqf\*(Aq (inclusive), the \& # hyphen (\*(Aq\-\*(Aq), or the letter \*(Aqm\*(Aq. \& [\*(Aq\-?] # Matches any of the characters \*(Aq()*+,\-./0123456789:;<=>? \& # (But not on an EBCDIC platform). .Ve .PP \fINegation\fR .IX Subsection "Negation" .PP It is also possible to instead list the characters you do not want to match. You can do so by using a caret (\f(CW\*(C`^\*(C'\fR) as the first character in the character class. For instance, \f(CW\*(C`[^a\-z]\*(C'\fR matches any character that is not a lowercase \s-1ASCII\s0 letter, which therefore includes more than a million Unicode code points. The class is said to be \*(L"negated\*(R" or \*(L"inverted\*(R". .PP This syntax make the caret a special character inside a bracketed character class, but only if it is the first character of the class. So if you want the caret as one of the characters to match, either escape the caret or else don't list it first. .PP In inverted bracketed character classes, Perl ignores the Unicode rules that normally say that certain characters should match a sequence of multiple characters under caseless \f(CW\*(C`/i\*(C'\fR matching. Following those rules could lead to highly confusing situations: .PP .Vb 1 \& "ss" =~ /^[^\exDF]+$/ui; # Matches! .Ve .PP This should match any sequences of characters that aren't \f(CW\*(C`\exDF\*(C'\fR nor what \f(CW\*(C`\exDF\*(C'\fR matches under \f(CW\*(C`/i\*(C'\fR. \f(CW"s"\fR isn't \f(CW\*(C`\exDF\*(C'\fR, but Unicode says that \f(CW"ss"\fR is what \f(CW\*(C`\exDF\*(C'\fR matches under \f(CW\*(C`/i\*(C'\fR. So which one \&\*(L"wins\*(R"? Do you fail the match because the string has \f(CW\*(C`ss\*(C'\fR or accept it because it has an \f(CW\*(C`s\*(C'\fR followed by another \f(CW\*(C`s\*(C'\fR? Perl has chosen the latter. .PP Examples: .PP .Vb 4 \& "e" =~ /[^aeiou]/ # No match, the \*(Aqe\*(Aq is listed. \& "x" =~ /[^aeiou]/ # Match, as \*(Aqx\*(Aq isn\*(Aqt a lowercase vowel. \& "^" =~ /[^^]/ # No match, matches anything that isn\*(Aqt a caret. \& "^" =~ /[x^]/ # Match, caret is not special here. .Ve .PP \fIBackslash Sequences\fR .IX Subsection "Backslash Sequences" .PP You can put any backslash sequence character class (with the exception of \&\f(CW\*(C`\eN\*(C'\fR and \f(CW\*(C`\eR\*(C'\fR) inside a bracketed character class, and it will act just as if you had put all characters matched by the backslash sequence inside the character class. For instance, \f(CW\*(C`[a\-f\ed]\*(C'\fR matches any decimal digit, or any of the lowercase letters between 'a' and 'f' inclusive. .PP \&\f(CW\*(C`\eN\*(C'\fR within a bracketed character class must be of the forms \f(CW\*(C`\eN{\f(CIname\f(CW}\*(C'\fR or \f(CW\*(C`\eN{U+\f(CIhex char\f(CW}\*(C'\fR, and \s-1NOT\s0 be the form that matches non-newlines, for the same reason that a dot \f(CW\*(C`.\*(C'\fR inside a bracketed character class loses its special meaning: it matches nearly anything, which generally isn't what you want to happen. .PP Examples: .PP .Vb 4 \& /[\ep{Thai}\ed]/ # Matches a character that is either a Thai \& # character, or a digit. \& /[^\ep{Arabic}()]/ # Matches a character that is neither an Arabic \& # character, nor a parenthesis. .Ve .PP Backslash sequence character classes cannot form one of the endpoints of a range. Thus, you can't say: .PP .Vb 1 \& /[\ep{Thai}\-\ed]/ # Wrong! .Ve .PP \fI\s-1POSIX\s0 Character Classes\fR .IX Xref "character class \\p \\p{} alpha alnum ascii blank cntrl digit graph lower print punct space upper word xdigit" .IX Subsection "POSIX Character Classes" .PP \&\s-1POSIX\s0 character classes have the form \f(CW\*(C`[:class:]\*(C'\fR, where \fIclass\fR is name, and the \f(CW\*(C`[:\*(C'\fR and \f(CW\*(C`:]\*(C'\fR delimiters. \s-1POSIX\s0 character classes only appear \&\fIinside\fR bracketed character classes, and are a convenient and descriptive way of listing a group of characters. .PP Be careful about the syntax, .PP .Vb 2 \& # Correct: \& $string =~ /[[:alpha:]]/ \& \& # Incorrect (will warn): \& $string =~ /[:alpha:]/ .Ve .PP The latter pattern would be a character class consisting of a colon, and the letters \f(CW\*(C`a\*(C'\fR, \f(CW\*(C`l\*(C'\fR, \f(CW\*(C`p\*(C'\fR and \f(CW\*(C`h\*(C'\fR. \&\s-1POSIX\s0 character classes can be part of a larger bracketed character class. For example, .PP .Vb 1 \& [01[:alpha:]%] .Ve .PP is valid and matches '0', '1', any alphabetic character, and the percent sign. .PP Perl recognizes the following \s-1POSIX\s0 character classes: .PP .Vb 10 \& alpha Any alphabetical character ("[A\-Za\-z]"). \& alnum Any alphanumeric character. ("[A\-Za\-z0\-9]") \& ascii Any character in the ASCII character set. \& blank A GNU extension, equal to a space or a horizontal tab ("\et"). \& cntrl Any control character. See Note [2] below. \& digit Any decimal digit ("[0\-9]"), equivalent to "\ed". \& graph Any printable character, excluding a space. See Note [3] below. \& lower Any lowercase character ("[a\-z]"). \& print Any printable character, including a space. See Note [4] below. \& punct Any graphical character excluding "word" characters. Note [5]. \& space Any whitespace character. "\es" plus the vertical tab ("\ecK"). \& upper Any uppercase character ("[A\-Z]"). \& word A Perl extension ("[A\-Za\-z0\-9_]"), equivalent to "\ew". \& xdigit Any hexadecimal digit ("[0\-9a\-fA\-F]"). .Ve .PP Most \s-1POSIX\s0 character classes have two Unicode-style \f(CW\*(C`\ep\*(C'\fR property counterparts. (They are not official Unicode properties, but Perl extensions derived from official Unicode properties.) The table below shows the relation between \s-1POSIX\s0 character classes and these counterparts. .PP One counterpart, in the column labelled \*(L"ASCII-range Unicode\*(R" in the table, matches only characters in the \s-1ASCII\s0 character set. .PP The other counterpart, in the column labelled \*(L"Full-range Unicode\*(R", matches any appropriate characters in the full Unicode character set. For example, \&\f(CW\*(C`\ep{Alpha}\*(C'\fR matches not just the \s-1ASCII\s0 alphabetic characters, but any character in the entire Unicode character set considered alphabetic. An entry in the column labelled \*(L"backslash sequence\*(R" is a (short) equivalent. .PP .Vb 10 \& [[:...:]] ASCII\-range Full\-range backslash Note \& Unicode Unicode sequence \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& alpha \ep{PosixAlpha} \ep{XPosixAlpha} \& alnum \ep{PosixAlnum} \ep{XPosixAlnum} \& ascii \ep{ASCII} \& blank \ep{PosixBlank} \ep{XPosixBlank} \eh [1] \& or \ep{HorizSpace} [1] \& cntrl \ep{PosixCntrl} \ep{XPosixCntrl} [2] \& digit \ep{PosixDigit} \ep{XPosixDigit} \ed \& graph \ep{PosixGraph} \ep{XPosixGraph} [3] \& lower \ep{PosixLower} \ep{XPosixLower} \& print \ep{PosixPrint} \ep{XPosixPrint} [4] \& punct \ep{PosixPunct} \ep{XPosixPunct} [5] \& \ep{PerlSpace} \ep{XPerlSpace} \es [6] \& space \ep{PosixSpace} \ep{XPosixSpace} [6] \& upper \ep{PosixUpper} \ep{XPosixUpper} \& word \ep{PosixWord} \ep{XPosixWord} \ew \& xdigit \ep{PosixXDigit} \ep{XPosixXDigit} .Ve .IP "[1]" 4 .IX Item "[1]" \&\f(CW\*(C`\ep{Blank}\*(C'\fR and \f(CW\*(C`\ep{HorizSpace}\*(C'\fR are synonyms. .IP "[2]" 4 .IX Item "[2]" Control characters don't produce output as such, but instead usually control the terminal somehow: for example, newline and backspace are control characters. In the \s-1ASCII\s0 range, characters whose code points are between 0 and 31 inclusive, plus 127 (\f(CW\*(C`DEL\*(C'\fR) are control characters. .Sp On \s-1EBCDIC\s0 platforms, it is likely that the code page will define \f(CW\*(C`[[:cntrl:]]\*(C'\fR to be the \s-1EBCDIC\s0 equivalents of the \s-1ASCII\s0 controls, plus the controls that in Unicode have code pointss from 128 through 159. .IP "[3]" 4 .IX Item "[3]" Any character that is \fIgraphical\fR, that is, visible. This class consists of all alphanumeric characters and all punctuation characters. .IP "[4]" 4 .IX Item "[4]" All printable characters, which is the set of all graphical characters plus those whitespace characters which are not also controls. .IP "[5]" 4 .IX Item "[5]" \&\f(CW\*(C`\ep{PosixPunct}\*(C'\fR and \f(CW\*(C`[[:punct:]]\*(C'\fR in the \s-1ASCII\s0 range match all non-controls, non-alphanumeric, non-space characters: \&\f(CW\*(C`[\-!"#$%&\*(Aq()*+,./:;<=>?@[\e\e\e]^_\`{|}~]\*(C'\fR (although if a locale is in effect, it could alter the behavior of \f(CW\*(C`[[:punct:]]\*(C'\fR). .Sp The similarly named property, \f(CW\*(C`\ep{Punct}\*(C'\fR, matches a somewhat different set in the \s-1ASCII\s0 range, namely \&\f(CW\*(C`[\-!"#%&\*(Aq()*,./:;?@[\e\e\e]_{}]\*(C'\fR. That is, it is missing the nine characters \f(CW\*(C`[$+<=>^\`|~]\*(C'\fR. This is because Unicode splits what \s-1POSIX\s0 considers to be punctuation into two categories, Punctuation and Symbols. .Sp \&\f(CW\*(C`\ep{XPosixPunct}\*(C'\fR and (under Unicode rules) \f(CW\*(C`[[:punct:]]\*(C'\fR, match what \&\f(CW\*(C`\ep{PosixPunct}\*(C'\fR matches in the \s-1ASCII\s0 range, plus what \f(CW\*(C`\ep{Punct}\*(C'\fR matches. This is different than strictly matching according to \&\f(CW\*(C`\ep{Punct}\*(C'\fR. Another way to say it is that if Unicode rules are in effect, \f(CW\*(C`[[:punct:]]\*(C'\fR matches all characters that Unicode considers punctuation, plus all ASCII-range characters that Unicode considers symbols. .IP "[6]" 4 .IX Item "[6]" \&\f(CW\*(C`\ep{SpacePerl}\*(C'\fR and \f(CW\*(C`\ep{Space}\*(C'\fR differ only in that in non-locale matching, \f(CW\*(C`\ep{Space}\*(C'\fR additionally matches the vertical tab, \f(CW\*(C`\ecK\*(C'\fR. Same for the two ASCII-only range forms. .PP There are various other synonyms that can be used besides the names listed in the table. For example, \f(CW\*(C`\ep{PosixAlpha}\*(C'\fR can be written as \&\f(CW\*(C`\ep{Alpha}\*(C'\fR. All are listed in \&\*(L"Properties accessible through \ep{} and \eP{}\*(R" in perluniprops, plus all characters matched by each ASCII-range property. .PP Both the \f(CW\*(C`\ep\*(C'\fR counterparts always assume Unicode rules are in effect. On \s-1ASCII\s0 platforms, this means they assume that the code points from 128 to 255 are Latin\-1, and that means that using them under locale rules is unwise unless the locale is guaranteed to be Latin\-1 or \s-1UTF\-8\s0. In contrast, the \&\s-1POSIX\s0 character classes are useful under locale rules. They are affected by the actual rules in effect, as follows: .ie n .IP "If the ""/a"" modifier, is in effect ..." 4 .el .IP "If the \f(CW/a\fR modifier, is in effect ..." 4 .IX Item "If the /a modifier, is in effect ..." Each of the \s-1POSIX\s0 classes matches exactly the same as their ASCII-range counterparts. .IP "otherwise ..." 4 .IX Item "otherwise ..." .RS 4 .PD 0 .IP "For code points above 255 ..." 4 .IX Item "For code points above 255 ..." .PD The \s-1POSIX\s0 class matches the same as its Full-range counterpart. .IP "For code points below 256 ..." 4 .IX Item "For code points below 256 ..." .RS 4 .PD 0 .IP "if locale rules are in effect ..." 4 .IX Item "if locale rules are in effect ..." .PD The \s-1POSIX\s0 class matches according to the locale, except that \&\f(CW\*(C`word\*(C'\fR uses the platform's native underscore character, no matter what the locale is. .IP "if Unicode rules are in effect or if on an \s-1EBCDIC\s0 platform ..." 4 .IX Item "if Unicode rules are in effect or if on an EBCDIC platform ..." The \s-1POSIX\s0 class matches the same as the Full-range counterpart. .IP "otherwise ..." 4 .IX Item "otherwise ..." The \s-1POSIX\s0 class matches the same as the \s-1ASCII\s0 range counterpart. .RE .RS 4 .RE .RE .RS 4 .RE .PP Which rules apply are determined as described in \&\*(L"Which character set modifier is in effect?\*(R" in perlre. .PP It is proposed to change this behavior in a future release of Perl so that whether or not Unicode rules are in effect would not change the behavior: Outside of locale or an \s-1EBCDIC\s0 code page, the \s-1POSIX\s0 classes would behave like their ASCII-range counterparts. If you wish to comment on this proposal, send email to \f(CW\*(C`perl5\-porters@perl.org\*(C'\fR. .PP Negation of \s-1POSIX\s0 character classes .IX Xref "character class, negation" .IX Subsection "Negation of POSIX character classes" .PP A Perl extension to the \s-1POSIX\s0 character class is the ability to negate it. This is done by prefixing the class name with a caret (\f(CW\*(C`^\*(C'\fR). Some examples: .PP .Vb 7 \& POSIX ASCII\-range Full\-range backslash \& Unicode Unicode sequence \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& [[:^digit:]] \eP{PosixDigit} \eP{XPosixDigit} \eD \& [[:^space:]] \eP{PosixSpace} \eP{XPosixSpace} \& \eP{PerlSpace} \eP{XPerlSpace} \eS \& [[:^word:]] \eP{PerlWord} \eP{XPosixWord} \eW .Ve .PP The backslash sequence can mean either \s-1ASCII\-\s0 or Full-range Unicode, depending on various factors as described in \*(L"Which character set modifier is in effect?\*(R" in perlre. .PP [= =] and [. .] .IX Subsection "[= =] and [. .]" .PP Perl recognizes the \s-1POSIX\s0 character classes \f(CW\*(C`[=class=]\*(C'\fR and \&\f(CW\*(C`[.class.]\*(C'\fR, but does not (yet?) support them. Any attempt to use either construct raises an exception. .PP Examples .IX Subsection "Examples" .PP .Vb 12 \& /[[:digit:]]/ # Matches a character that is a digit. \& /[01[:lower:]]/ # Matches a character that is either a \& # lowercase letter, or \*(Aq0\*(Aq or \*(Aq1\*(Aq. \& /[[:digit:][:^xdigit:]]/ # Matches a character that can be anything \& # except the letters \*(Aqa\*(Aq to \*(Aqf\*(Aq. This is \& # because the main character class is composed \& # of two POSIX character classes that are ORed \& # together, one that matches any digit, and \& # the other that matches anything that isn\*(Aqt a \& # hex digit. The result matches all \& # characters except the letters \*(Aqa\*(Aq to \*(Aqf\*(Aq and \& # \*(AqA\*(Aq to \*(AqF\*(Aq. .Vey~or5J={Eeu磝Qk ᯘG{?+]ן?wM3X^歌>{7پK>on\jy Rg/=fOroNVv~Y+ NGuÝHWyw[eQʨSb> >}Gmx[o[<{Ϯ_qFvM IENDB`