您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > Mastering Regular Expressions
MasteringRegularExpressions(miniversion)JeffreyE.F.Friedl1stEditionJanuary19971-56592-257-3,366pagesRegularexpressions,apowerfultoolformanipulatingtextanddata,arefoundinscriptinglanguages,editors,programmingenvironments,andspecializedtools.Inthisbook,authorJeffreyFriedlleadsyouthroughthestepsofcraftingaregularexpressionthatgetsthejobdone.Heexaminesavarietyoftoolsandusestheminanextensivearrayofexamples,withamajorfocusonPerl.ReleaseTeam[oR]2001Preface1WhyIWroteThisBookIntendedAudience1Introductiontoregularexpressions21.1Whatareregularexpressionsusedfor1.2Solvingrealproblems1.3Regularexpressionsasalanguage1.4Thefilenameanalogy1.5Thelanguageanalogy1.6Theregularexpressionfrominmind1.7Searchingtextfiles1.8Grep,egrep,fgrep,perl,saywhat?2Characterclasses52.1Matchinglistofcharacters2.2Negatedcharacterclasses2.3Characterclassandspecialcharacters2.4POSIXlocalesandcharacterclasses3Regularexpressionssyntax93.1Markingstartandend3.2Matchinganycharacter3.3Alternationandgrouping3.4Alternationandanchors3.5Wordboundaries3.6Quantifiers(basic,greedy)3.7Quantifiers(basic,additional)3.8Quantifiers(extended,non-greedy)3.9Ignoringcase3.10Parenthesesandbackreferences3.11Problemswithparentheses3.12Theescapecharacter-backslash3.13Backslashcharacternotationinregularexpressions3.14Lineendings\r\nandoperatingsystems3.15Perlshorthandregularexpressions4Perlzerowidthassertions184.1Beginningofline(^)and(\A)4.2Endofline($)and(\Z)and(\z)4.3Word(\b)andnon-word(\B)boundaries4.4Matchcontinuefromlastposition(\G)5PerlRegularexpressionmodifiers205.1Perlmatchoperator5.2Perlsubstitutecommand5.3Modifiersinmatches5.4Donotresetpositionorcontinue(c)5.5Globalmatching(g)5.6Ignorecase(i)5.7Lockregularexpression(o)5.8Spanmultiplelines(m)5.9Singlelinematchesanddot(s)5.10Extendedwritingmode(x)5.11Evaluateperlcode(e)6PerlExtendedregularexpressionpatterns256.1Comment(?#text)6.2Modifiers(?imsx-imsx)6.3Non-capturingparenthesis(?:pattern)6.4Zero-widthpositivelookahead(?=pattern)6.5Zero-widthnegativelookahead(?!pattern)6.6Zero-widthpositivelookbehind(?=pattern)6.7Zero-widthnegativelookbehind(?!pattern)6.8Zero-widthPerlevalassertion(?{code})6.9Postponedexpression(??{code})6.10Independentsubexpression(?pattern)6.11Conditionalpattern(?(condition)yes-pattern|no-pattern)7Regularexpressiondiscussion287.1Matchingnumericranges7.2Payattentiontotheuseof.*7.3Variablenames7.4AStringwithindoublequotes7.5Dollaramountwithoptionalcents7.6Matchingrangeofnumbers7.7Matchingtemperaturevalues7.8Matchingwhitespace7.9MatchingtextbetweenHTMLtags7.10Matchingsomethinginsideparenthesis7.11Reducingnumberofdecimalstothree(substituting)8Differentregularexpressionengines338.1Regexpenginetypes8.2NFAenginereliesonregexp(Perl,Emacs)8.3DFAenginereadstext8.4Craftingregularexpressions8.5Differencesincapabilities9AppendixA-regularexpressions369.1Perlregularexpressionsyntax9.2Regularexpressionengines9.3Regularexpressionrules9.4Howtowritegoodregularexpressions9.5Understandingnegativelookahead10AppendixB-Perllanguage4010.1Perlmanualpages10.2UsefulPerlcommandlineswitches10.3PerlenvironmentvariablesMasteringRegularExpressionspage1PrefaceThisbookisaboutapowerfultoolcalledregularexpressions.Here,youwilllearnhowtouseregularexpressionstosolveproblemsandgetthemostoutoftoolsthatprovidethem.Notonlythat,butmuchmore:thisbookisaboutmasteringregularexpressions.Ifyouuseacomputer,youcanbenefitfromregularexpressionsallthetime(evenifyoudon'trealizeit).WhenaccessingWorldWideWebsearchengines,withyoureditor,wordprocessor,configurationscripts,andsystemtools,regularexpressionsareoftenprovidedaspoweruseroptions.LanguagessuchasAwk,Elisp,Expect,Perl,Python,andTclhaveregular-expressionsupportbuiltin(regularexpressionsaretheveryheartofmanyprogramswrittenintheselanguages),andregular-expressionlibrariesareavailableformostotherlanguages.Forexample,quitesoonafterJavabecameavailable,aregular-expressionlibrarywasbuiltandmadefreelyavailableontheWeb.Regularexpressionsarefoundineditorsandprogrammingenvironmentssuchasvi,Delphi,Emacs,Brief,VisualC++,NisusWriter,andmany,manymore.Regularexpressionsareverypopular.There'sagoodreasonthatregularexpressionsarefoundinsomanydiverseapplications:theyareextremelypowerful.Atalowlevel,aregularexpressiondescribesachunkoftext.Youmightuseittoverifyauser'sinput,orperhapstosiftthroughlargeamountsofdata.Onahigherlevel,regularexpressionsallowyoutomasteryourdata.Controlit.Putittoworkforyou.Tomasterregularexpressionsistomasteryourdata.WhyIWroteThisBookYoumightthinkthatwiththeirwideavailability,generalpopularity,andunparalleledpower,regularexpressionswouldbeemployedtotheirfullest,whereverfound.Youmightalsothinkthattheywouldbewelldocumented,withintroductorytutorialsforthenovicejuststartingout,andadvancedmanualsfortheexpertdesiringthatlittleextraedge.Sadly,thathasn'tbeenthecase.Regular-expressiondocumentationiscertainlyplentiful,andhasbeenavailableforalongtime.(Ireadmyfirstregular-expression-relatedmanualbackin1981.)Theproblem,itseems,isthatthedocumentationhastraditionallycenteredonthelow-levelviewthatImentionedamome
本文标题:Mastering Regular Expressions
链接地址:https://www.777doc.com/doc-4281113 .html