📄 perlrebackslash.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...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 (.Sh), 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 "PERLREBACKSLASH 1".TH PERLREBACKSLASH 1 "2007-12-18" "perl v5.10.0" "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"perlrebackslash \- Perl Regular Expression Backslash Sequences and Escapes.SH "DESCRIPTION".IX Header "DESCRIPTION"The top level documentation about Perl regular expressionsis found in perlre..PPThis document describes all backslash and escape sequences. Afterexplaining the role of the backslash, it lists all the sequences that havea special meaning in Perl regular expressions (in alphabetical order),then describes each of them..PPMost sequences are described in detail in different documents; the primarypurpose of this document is to have a quick reference guide describing allbackslash and escape sequences..Sh "The backslash".IX Subsection "The backslash"In a regular expression, the backslash can perform one of two tasks:it either takes away the special meaning of the character following it(for instance, \f(CW\*(C`\e|\*(C'\fR matches a vertical bar, it's not an alternation),or it is the start of a backslash or escape sequence..PPThe rules determining what it is are quite simple: if the characterfollowing the backslash is a punctuation (non-word) character (that is,anything that is not a letter, digit or underscore), then the backslashjust takes away the special meaning (if any) of the character followingit..PPIf the character following the backslash is a letter or a digit, then thesequence may be special; if so, it's listed below. A few letters have notbeen used yet, and escaping them with a backslash is safe for now, but afuture version of Perl may assign a special meaning to it. However, if youhave warnings turned on, Perl will issue a warning if you use such a sequence.[1]..PPIt is however guaranteed that backslash or escape sequences never have apunctuation character following the backslash, not now, and not in a futureversion of Perl 5. So it is safe to put a backslash in front of a non-wordcharacter..PPNote that the backslash itself is special; if you want to match a backslash,you have to escape the backslash with a backslash: \f(CW\*(C`/\e\e/\*(C'\fR matches a singlebackslash..IP "[1]" 4.IX Item "[1]"There is one exception. If you use an alphanumerical character as thedelimiter of your pattern (which you probably shouldn't do for readabilityreasons), you will have to escape the delimiter if you want to matchit. Perl won't warn then. See also \*(L"Gory details of parsingquoted constructs\*(R" in perlop..Sh "All the sequences and escapes".IX Subsection "All the sequences and escapes".Vb 10\& \e000 Octal escape sequence.\& \e1 Absolute backreference.\& \ea Alarm or bell.\& \eA Beginning of string.\& \eb Word/non\-word boundary. (Backspace in a char class).\& \eB Not a word/non\-word boundary.\& \ecX Control\-X (X can be any ASCII character).\& \eC Single octet, even under UTF\-8.\& \ed Character class for digits.\& \eD Character class for non\-digits.\& \ee Escape character.\& \eE Turn off \eQ, \eL and \eU processing.\& \ef Form feed.\& \eg{}, \eg1 Named, absolute or relative backreference.\& \eG Pos assertion.\& \eh Character class for horizontal white space.\& \eH Character class for non horizontal white space.\& \ek{}, \ek<>, \ek\*(Aq\*(Aq Named backreference.\& \eK Keep the stuff left of \eK.\& \el Lowercase next character.\& \eL Lowercase till \eE.\& \en (Logical) newline character.\& \eN{} Named (Unicode) character.\& \ep{}, \epP Character with a Unicode property.\& \eP{}, \ePP Character without a Unicode property.\& \eQ Quotemeta till \eE.\& \er Return character.\& \eR Generic new line.\& \es Character class for white space.\& \eS Character class for non white space.\& \et Tab character.\& \eu Titlecase next character.\& \eU Uppercase till \eE.\& \ev Character class for vertical white space.\& \eV Character class for non vertical white space.\& \ew Character class for word characters.\& \eW Character class for non\-word characters.\& \ex{}, \ex00 Hexadecimal escape sequence.\& \eX Extended Unicode "combining character sequence".\& \ez End of string.\& \eZ End of string..Ve.Sh "Character Escapes".IX Subsection "Character Escapes"\fIFixed characters\fR.IX Subsection "Fixed characters".PPA handful of characters have a dedicated \fIcharacter escape\fR. The followingtable shows them, along with their code points (in decimal and hex), their\&\s-1ASCII\s0 name, the control escape (see below) and a short description..PP.Vb 9\& Seq. Code Point ASCII Cntr Description.\& Dec Hex\& \ea 7 07 BEL \ecG alarm or bell\& \eb 8 08 BS \ecH backspace [1]\& \ee 27 1B ESC \ec[ escape character\& \ef 12 0C FF \ecL form feed\& \en 10 0A LF \ecJ line feed [2]\& \er 13 0D CR \ecM carriage return\& \et 9 09 TAB \ecI tab.Ve.IP "[1]" 4.IX Item "[1]"\&\f(CW\*(C`\eb\*(C'\fR is only the backspace character inside a character class. Outside acharacter class, \f(CW\*(C`\eb\*(C'\fR is a word/non\-word boundary..IP "[2]" 4.IX Item "[2]"\&\f(CW\*(C`\en\*(C'\fR matches a logical newline. Perl will convert between \f(CW\*(C`\en\*(C'\fR and yourOSses native newline character when reading from or writing to text files..PPExample.IX Subsection "Example".PP.Vb 1\& $str =~ /\et/; # Matches if $str contains a (horizontal) tab..Ve.PP\fIControl characters\fR.IX Subsection "Control characters".PP\&\f(CW\*(C`\ec\*(C'\fR is used to denote a control character; the character following \f(CW\*(C`\ec\*(C'\fRis the name of the control character. For instance, \f(CW\*(C`/\ecM/\*(C'\fR matches thecharacter \fIcontrol-M\fR (a carriage return, code point 13). The case of thecharacter following \f(CW\*(C`\ec\*(C'\fR doesn't matter: \f(CW\*(C`\ecM\*(C'\fR and \f(CW\*(C`\ecm\*(C'\fR match the samecharacter..PPMnemonic: \fIc\fRontrol character..PPExample.IX Subsection "Example".PP.Vb 1\& $str =~ /\ecK/; # Matches if $str contains a vertical tab (control\-K)..Ve.PP\fINamed characters\fR.IX Subsection "Named characters".PPAll Unicode characters have a Unicode name, and characters in various scriptshave names as well. It is even possible to give your own names to characters.You can use a character by name by using the \f(CW\*(C`\eN{}\*(C'\fR construct; the name ofthe character goes between the curly braces. You do have to \f(CW\*(C`use charnames\*(C'\fRto load the names of the characters, otherwise Perl will complain you usea name it doesn't know about. For more details, see charnames..PPMnemonic: \fIN\fRamed character..PPExample.IX Subsection "Example".PP.Vb 2\& use charnames \*(Aq:full\*(Aq; # Loads the Unicode names.\& $str =~ /\eN{THAI CHARACTER SO SO}/; # Matches the Thai SO SO character\&\& use charnames \*(AqCyrillic\*(Aq; # Loads Cyrillic names.\& $str =~ /\eN{ZHE}\eN{KA}/; # Match "ZHE" followed by "KA"..Ve.PP\fIOctal escapes\fR.IX Subsection "Octal escapes".PPOctal escapes consist of a backslash followed by two or three octal digitsmatching the code point of the character you want to use. This allows for512 characters (\f(CW\*(C`\e00\*(C'\fR up to \f(CW\*(C`\e777\*(C'\fR) that can be expressed this way.Enough in pre-Unicode days, but most Unicode characters cannot be escapedthis way..PPNote that a character that is expressed as an octal escape is consideredas a character without special meaning by the regex engine, and will match\&\*(L"as is\*(R"..PPExamples.IX Subsection "Examples".PP.Vb 4\& $str = "Perl";\& $str =~ /\e120/; # Match, "\e120" is "P".\& $str =~ /\e120+/; # Match, "\e120" is "P", it is repeated at least once.\& $str =~ /P\e053/; # No match, "\e053" is "+" and taken literally..Ve.PPCaveat.IX Subsection "Caveat"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -