perlre - Perl regular expressions - Perldoc Browser
文章推薦指數: 80 %
DESCRIPTION. This page describes the syntax of regular expressions in Perl. If you haven't used regular expressions before, a tutorial introduction is available ...
PerldocBrowser
5.36.0
Latest
5.36.0
5.34.1
5.34.0
5.32.1
5.32.0
5.30.3
5.30.2
5.30.1
5.30.0
5.28.3
5.28.2
5.28.1
5.28.0
5.26.3
5.26.2
5.26.1
5.26.0
5.24.4
5.24.3
5.24.2
5.24.1
5.24.0
5.22.4
5.22.3
5.22.2
5.22.1
5.22.0
5.20.3
5.20.2
5.20.1
5.20.0
5.18.4
5.18.3
5.18.2
5.18.1
5.18.0
5.16.3
5.16.2
5.16.1
5.16.0
5.14.4
5.14.3
5.14.2
5.14.1
5.14.0
5.12.5
5.12.4
5.12.3
5.12.2
5.12.1
5.12.0
5.10.1
5.10.0
5.8.9
5.8.8
5.8.7
5.8.6
5.8.5
5.8.4
5.8.3
5.8.2
5.8.1
5.8.0
5.6.2
5.6.1
5.6.0
5.005_04
5.005_03
5.005_02
5.005_01
5.005
Dev
blead
5.37.1
5.37.0
5.36.0-RC3
5.36.0-RC2
5.35.11
5.35.10
5.35.9
5.35.8
5.35.7
5.35.6
5.35.5
5.35.4
5.35.3
5.35.2
5.35.1
5.35.0
5.33.9
5.33.8
5.33.7
5.33.6
5.33.5
5.33.4
5.33.3
5.33.2
5.33.1
5.33.0
Documentation
Perl
Intro
Tutorials
FAQs
Reference
Operators
Functions
Variables
Modules
Utilities
Community
History
Expand
perlre
(source,
CPAN)
CONTENTS
NAME
DESCRIPTION
TheBasics
Metacharacters
Modifiers
Overview
Detailsonsomemodifiers
/xand/xx
Charactersetmodifiers
/l
/u
/d
/a(and/aa)
Whichcharactersetmodifierisineffect?
CharactersetmodifierbehaviorpriortoPerl5.14
RegularExpressions
Quantifiers
Escapesequences
CharacterClassesandotherSpecialEscapes
Assertions
Capturegroups
Quotingmetacharacters
ExtendedPatterns
Backtracking
ScriptRuns
SpecialBacktrackingControlVerbs
Warningon\1Insteadof$1
RepeatedPatternsMatchingaZero-lengthSubstring
CombiningREPieces
CreatingCustomREEngines
EmbeddedCodeExecutionFrequency
PCRE/PythonSupport
BUGS
SEEALSO
#NAME
perlre-Perlregularexpressions
#DESCRIPTION
ThispagedescribesthesyntaxofregularexpressionsinPerl.
Ifyouhaven'tusedregularexpressionsbefore,atutorialintroductionisavailableinperlretut.Ifyouknowjustalittleaboutthem,aquick-startintroductionisavailableinperlrequick.
Exceptfor"TheBasics"section,thispageassumesyouarefamiliarwithregularexpressionbasics,likewhatisa"pattern",whatdoesitlooklike,andhowitisbasicallyused.Forareferenceonhowtheyareused,plusvariousexamplesofthesame,seediscussionsofm//,s///,qr//and"??"in"RegexpQuote-LikeOperators"inperlop.
Newinv5.22,usere'strict'appliesstricterrulesthanotherwisewhencompilingregularexpressionpatterns.Itcanfindthingsthat,whilelegal,maynotbewhatyouintended.
#TheBasics
Regularexpressionsarestringswiththeveryparticularsyntaxandmeaningdescribedinthisdocumentandauxiliarydocumentsreferredtobythisone.Thestringsarecalled"patterns".Patternsareusedtodetermineifsomeotherstring,calledthe"target",has(ordoesn'thave)thecharacteristicsspecifiedbythepattern.Wecallthis"matching"thetargetstringagainstthepattern.Usuallythematchisdonebyhavingthetargetbethefirstoperand,andthepatternbethesecondoperand,ofoneofthetwobinaryoperators=~and!~,listedin"BindingOperators"inperlop;andthepatternwillhavebeenconvertedfromanordinarystringbyoneoftheoperatorsin"RegexpQuote-LikeOperators"inperlop,likeso:
$foo=~m/abc/
Thisevaluatestotrueifandonlyifthestringinthevariable$foocontainssomewhereinit,thesequenceofcharacters"a","b",then"c".(The=~m,ormatchoperator,isdescribedin"m/PATTERN/msixpodualngc"inperlop.)
Patternsthataren'talreadystoredinsomevariablemustbedelimited,atbothends,bydelimitercharacters.Theseareoften,asintheexampleabove,forwardslashes,andthetypicalwayapatterniswrittenindocumentationiswiththoseslashes.Inmostcases,thedelimiteristhesamecharacter,foreandaft,butthereareafewcaseswhereacharacterlookslikeithasamirror-imagemate,wheretheopeningversionisthebeginningdelimiter,andtheclosingoneistheendingdelimiter,like
$foo=~m
延伸文章資訊
- 1Perl - Regular Expressions - Tutorialspoint
A regular expression is a string of characters that defines the pattern or patterns you are viewi...
- 2Perl | Regex Cheat Sheet - GeeksforGeeks
Regex or Regular Expressions are an important part of Perl Programming. It is used for searching ...
- 3Perl | Regular Expressions - GeeksforGeeks
- 4Perl regex tutorial: non-greedy-expressions - UltraEdit
Perl regex tutorial: non-greedy expressions. Have you ever built a complex Perl-style regular exp...
- 5perlre - Perl regular expressions - Perldoc Browser
DESCRIPTION. This page describes the syntax of regular expressions in Perl. If you haven't used r...