testinput1 118 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438
  1. # This set of tests is for features that are compatible with all versions of
  2. # Perl >= 5.10, in non-UTF mode. It should run clean for the 8-bit, 16-bit, and
  3. # 32-bit PCRE libraries, and also using the perltest.sh script.
  4. # WARNING: Use only / as the pattern delimiter. Although pcre2test supports
  5. # a number of delimiters, all those other than / give problems with the
  6. # perltest.sh script.
  7. #forbid_utf
  8. #newline_default lf any anycrlf
  9. #perltest
  10. /the quick brown fox/
  11. the quick brown fox
  12. What do you know about the quick brown fox?
  13. \= Expect no match
  14. The quick brown FOX
  15. What do you know about THE QUICK BROWN FOX?
  16. /The quick brown fox/i
  17. the quick brown fox
  18. The quick brown FOX
  19. What do you know about the quick brown fox?
  20. What do you know about THE QUICK BROWN FOX?
  21. /abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
  22. abcd\t\n\r\f\a\e9;\$\\?caxyz
  23. /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
  24. abxyzpqrrrabbxyyyypqAzz
  25. abxyzpqrrrabbxyyyypqAzz
  26. aabxyzpqrrrabbxyyyypqAzz
  27. aaabxyzpqrrrabbxyyyypqAzz
  28. aaaabxyzpqrrrabbxyyyypqAzz
  29. abcxyzpqrrrabbxyyyypqAzz
  30. aabcxyzpqrrrabbxyyyypqAzz
  31. aaabcxyzpqrrrabbxyyyypAzz
  32. aaabcxyzpqrrrabbxyyyypqAzz
  33. aaabcxyzpqrrrabbxyyyypqqAzz
  34. aaabcxyzpqrrrabbxyyyypqqqAzz
  35. aaabcxyzpqrrrabbxyyyypqqqqAzz
  36. aaabcxyzpqrrrabbxyyyypqqqqqAzz
  37. aaabcxyzpqrrrabbxyyyypqqqqqqAzz
  38. aaaabcxyzpqrrrabbxyyyypqAzz
  39. abxyzzpqrrrabbxyyyypqAzz
  40. aabxyzzzpqrrrabbxyyyypqAzz
  41. aaabxyzzzzpqrrrabbxyyyypqAzz
  42. aaaabxyzzzzpqrrrabbxyyyypqAzz
  43. abcxyzzpqrrrabbxyyyypqAzz
  44. aabcxyzzzpqrrrabbxyyyypqAzz
  45. aaabcxyzzzzpqrrrabbxyyyypqAzz
  46. aaaabcxyzzzzpqrrrabbxyyyypqAzz
  47. aaaabcxyzzzzpqrrrabbbxyyyypqAzz
  48. aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
  49. aaabcxyzpqrrrabbxyyyypABzz
  50. aaabcxyzpqrrrabbxyyyypABBzz
  51. >>>aaabxyzpqrrrabbxyyyypqAzz
  52. >aaaabxyzpqrrrabbxyyyypqAzz
  53. >>>>abcxyzpqrrrabbxyyyypqAzz
  54. \= Expect no match
  55. abxyzpqrrabbxyyyypqAzz
  56. abxyzpqrrrrabbxyyyypqAzz
  57. abxyzpqrrrabxyyyypqAzz
  58. aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
  59. aaaabcxyzzzzpqrrrabbbxyyypqAzz
  60. aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
  61. /^(abc){1,2}zz/
  62. abczz
  63. abcabczz
  64. \= Expect no match
  65. zz
  66. abcabcabczz
  67. >>abczz
  68. /^(b+?|a){1,2}?c/
  69. bc
  70. bbc
  71. bbbc
  72. bac
  73. bbac
  74. aac
  75. abbbbbbbbbbbc
  76. bbbbbbbbbbbac
  77. \= Expect no match
  78. aaac
  79. abbbbbbbbbbbac
  80. /^(b+|a){1,2}c/
  81. bc
  82. bbc
  83. bbbc
  84. bac
  85. bbac
  86. aac
  87. abbbbbbbbbbbc
  88. bbbbbbbbbbbac
  89. \= Expect no match
  90. aaac
  91. abbbbbbbbbbbac
  92. /^(ba|b*){1,2}?bc/
  93. babc
  94. bbabc
  95. bababc
  96. \= Expect no match
  97. bababbc
  98. babababc
  99. /^\ca\cA\c[;\c:/
  100. \x01\x01\e;z
  101. /^[ab\]cde]/
  102. athing
  103. bthing
  104. ]thing
  105. cthing
  106. dthing
  107. ething
  108. \= Expect no match
  109. fthing
  110. [thing
  111. \\thing
  112. /^[]cde]/
  113. ]thing
  114. cthing
  115. dthing
  116. ething
  117. \= Expect no match
  118. athing
  119. fthing
  120. /^[^ab\]cde]/
  121. fthing
  122. [thing
  123. \\thing
  124. \= Expect no match
  125. athing
  126. bthing
  127. ]thing
  128. cthing
  129. dthing
  130. ething
  131. /^[^]cde]/
  132. athing
  133. fthing
  134. \= Expect no match
  135. ]thing
  136. cthing
  137. dthing
  138. ething
  139. /^\�/
  140. /^ÿ/
  141. ÿ
  142. /^[0-9]+$/
  143. 0
  144. 1
  145. 2
  146. 3
  147. 4
  148. 5
  149. 6
  150. 7
  151. 8
  152. 9
  153. 10
  154. 100
  155. \= Expect no match
  156. abc
  157. /^.*nter/
  158. enter
  159. inter
  160. uponter
  161. /^xxx[0-9]+$/
  162. xxx0
  163. xxx1234
  164. \= Expect no match
  165. xxx
  166. /^.+[0-9][0-9][0-9]$/
  167. x123
  168. x1234
  169. xx123
  170. 123456
  171. \= Expect no match
  172. 123
  173. /^.+?[0-9][0-9][0-9]$/
  174. x123
  175. x1234
  176. xx123
  177. 123456
  178. \= Expect no match
  179. 123
  180. /^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
  181. abc!pqr=apquxz.ixr.zzz.ac.uk
  182. \= Expect no match
  183. !pqr=apquxz.ixr.zzz.ac.uk
  184. abc!=apquxz.ixr.zzz.ac.uk
  185. abc!pqr=apquxz:ixr.zzz.ac.uk
  186. abc!pqr=apquxz.ixr.zzz.ac.ukk
  187. /:/
  188. Well, we need a colon: somewhere
  189. \= Expect no match
  190. Fail without a colon
  191. /([\da-f:]+)$/i
  192. 0abc
  193. abc
  194. fed
  195. E
  196. ::
  197. 5f03:12C0::932e
  198. fed def
  199. Any old stuff
  200. \= Expect no match
  201. 0zzz
  202. gzzz
  203. fed\x20
  204. Any old rubbish
  205. /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
  206. .1.2.3
  207. A.12.123.0
  208. \= Expect no match
  209. .1.2.3333
  210. 1.2.3
  211. 1234.2.3
  212. /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
  213. 1 IN SOA non-sp1 non-sp2(
  214. 1 IN SOA non-sp1 non-sp2 (
  215. \= Expect no match
  216. 1IN SOA non-sp1 non-sp2(
  217. /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
  218. a.
  219. Z.
  220. 2.
  221. ab-c.pq-r.
  222. sxk.zzz.ac.uk.
  223. x-.y-.
  224. \= Expect no match
  225. -abc.peq.
  226. /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
  227. *.a
  228. *.b0-a
  229. *.c3-b.c
  230. *.c-a.b-c
  231. \= Expect no match
  232. *.0
  233. *.a-
  234. *.a-b.c-
  235. *.c-a.0-c
  236. /^(?=ab(de))(abd)(e)/
  237. abde
  238. /^(?!(ab)de|x)(abd)(f)/
  239. abdf
  240. /^(?=(ab(cd)))(ab)/
  241. abcd
  242. /^[\da-f](\.[\da-f])*$/i
  243. a.b.c.d
  244. A.B.C.D
  245. a.b.c.1.2.3.C
  246. /^\".*\"\s*(;.*)?$/
  247. \"1234\"
  248. \"abcd\" ;
  249. \"\" ; rhubarb
  250. \= Expect no match
  251. \"1234\" : things
  252. /^$/
  253. \
  254. \= Expect no match
  255. A non-empty line
  256. / ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
  257. ab c
  258. \= Expect no match
  259. abc
  260. ab cde
  261. /(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
  262. ab c
  263. \= Expect no match
  264. abc
  265. ab cde
  266. /^ a\ b[c ]d $/x
  267. a bcd
  268. a b d
  269. \= Expect no match
  270. abcd
  271. ab d
  272. /^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
  273. abcdefhijklm
  274. /^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
  275. abcdefhijklm
  276. /^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
  277. a+ Z0+\x08\n\x1d\x12
  278. /^[.^$|()*+?{,}]+/
  279. .^\$(*+)|{?,?}
  280. /^a*\w/
  281. z
  282. az
  283. aaaz
  284. a
  285. aa
  286. aaaa
  287. a+
  288. aa+
  289. /^a*?\w/
  290. z
  291. az
  292. aaaz
  293. a
  294. aa
  295. aaaa
  296. a+
  297. aa+
  298. /^a+\w/
  299. az
  300. aaaz
  301. aa
  302. aaaa
  303. aa+
  304. /^a+?\w/
  305. az
  306. aaaz
  307. aa
  308. aaaa
  309. aa+
  310. /^\d{8}\w{2,}/
  311. 1234567890
  312. 12345678ab
  313. 12345678__
  314. \= Expect no match
  315. 1234567
  316. /^[aeiou\d]{4,5}$/
  317. uoie
  318. 1234
  319. 12345
  320. aaaaa
  321. \= Expect no match
  322. 123456
  323. /^[aeiou\d]{4,5}?/
  324. uoie
  325. 1234
  326. 12345
  327. aaaaa
  328. 123456
  329. /\A(abc|def)=(\1){2,3}\Z/
  330. abc=abcabc
  331. def=defdefdef
  332. \= Expect no match
  333. abc=defdef
  334. /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
  335. abcdefghijkcda2
  336. abcdefghijkkkkcda2
  337. /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
  338. cataract cataract23
  339. catatonic catatonic23
  340. caterpillar caterpillar23
  341. /^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
  342. From abcd Mon Sep 01 12:33:02 1997
  343. /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
  344. From abcd Mon Sep 01 12:33:02 1997
  345. From abcd Mon Sep 1 12:33:02 1997
  346. \= Expect no match
  347. From abcd Sep 01 12:33:02 1997
  348. /^12.34/s
  349. 12\n34
  350. 12\r34
  351. /\w+(?=\t)/
  352. the quick brown\t fox
  353. /foo(?!bar)(.*)/
  354. foobar is foolish see?
  355. /(?:(?!foo)...|^.{0,2})bar(.*)/
  356. foobar crowbar etc
  357. barrel
  358. 2barrel
  359. A barrel
  360. /^(\D*)(?=\d)(?!123)/
  361. abc456
  362. \= Expect no match
  363. abc123
  364. /^1234(?# test newlines
  365. inside)/
  366. 1234
  367. /^1234 #comment in extended re
  368. /x
  369. 1234
  370. /#rhubarb
  371. abcd/x
  372. abcd
  373. /^abcd#rhubarb/x
  374. abcd
  375. /^(a)\1{2,3}(.)/
  376. aaab
  377. aaaab
  378. aaaaab
  379. aaaaaab
  380. /(?!^)abc/
  381. the abc
  382. \= Expect no match
  383. abc
  384. /(?=^)abc/
  385. abc
  386. \= Expect no match
  387. the abc
  388. /^[ab]{1,3}(ab*|b)/
  389. aabbbbb
  390. /^[ab]{1,3}?(ab*|b)/
  391. aabbbbb
  392. /^[ab]{1,3}?(ab*?|b)/
  393. aabbbbb
  394. /^[ab]{1,3}(ab*?|b)/
  395. aabbbbb
  396. / (?: [\040\t] | \(
  397. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  398. \) )* # optional leading comment
  399. (?: (?:
  400. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  401. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  402. |
  403. " (?: # opening quote...
  404. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  405. | # or
  406. \\ [^\x80-\xff] # Escaped something (something != CR)
  407. )* " # closing quote
  408. ) # initial word
  409. (?: (?: [\040\t] | \(
  410. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  411. \) )* \. (?: [\040\t] | \(
  412. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  413. \) )* (?:
  414. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  415. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  416. |
  417. " (?: # opening quote...
  418. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  419. | # or
  420. \\ [^\x80-\xff] # Escaped something (something != CR)
  421. )* " # closing quote
  422. ) )* # further okay, if led by a period
  423. (?: [\040\t] | \(
  424. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  425. \) )* @ (?: [\040\t] | \(
  426. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  427. \) )* (?:
  428. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  429. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  430. | \[ # [
  431. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  432. \] # ]
  433. ) # initial subdomain
  434. (?: #
  435. (?: [\040\t] | \(
  436. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  437. \) )* \. # if led by a period...
  438. (?: [\040\t] | \(
  439. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  440. \) )* (?:
  441. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  442. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  443. | \[ # [
  444. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  445. \] # ]
  446. ) # ...further okay
  447. )*
  448. # address
  449. | # or
  450. (?:
  451. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  452. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  453. |
  454. " (?: # opening quote...
  455. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  456. | # or
  457. \\ [^\x80-\xff] # Escaped something (something != CR)
  458. )* " # closing quote
  459. ) # one word, optionally followed by....
  460. (?:
  461. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or...
  462. \(
  463. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  464. \) | # comments, or...
  465. " (?: # opening quote...
  466. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  467. | # or
  468. \\ [^\x80-\xff] # Escaped something (something != CR)
  469. )* " # closing quote
  470. # quoted strings
  471. )*
  472. < (?: [\040\t] | \(
  473. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  474. \) )* # leading <
  475. (?: @ (?: [\040\t] | \(
  476. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  477. \) )* (?:
  478. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  479. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  480. | \[ # [
  481. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  482. \] # ]
  483. ) # initial subdomain
  484. (?: #
  485. (?: [\040\t] | \(
  486. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  487. \) )* \. # if led by a period...
  488. (?: [\040\t] | \(
  489. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  490. \) )* (?:
  491. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  492. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  493. | \[ # [
  494. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  495. \] # ]
  496. ) # ...further okay
  497. )*
  498. (?: (?: [\040\t] | \(
  499. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  500. \) )* , (?: [\040\t] | \(
  501. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  502. \) )* @ (?: [\040\t] | \(
  503. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  504. \) )* (?:
  505. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  506. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  507. | \[ # [
  508. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  509. \] # ]
  510. ) # initial subdomain
  511. (?: #
  512. (?: [\040\t] | \(
  513. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  514. \) )* \. # if led by a period...
  515. (?: [\040\t] | \(
  516. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  517. \) )* (?:
  518. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  519. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  520. | \[ # [
  521. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  522. \] # ]
  523. ) # ...further okay
  524. )*
  525. )* # further okay, if led by comma
  526. : # closing colon
  527. (?: [\040\t] | \(
  528. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  529. \) )* )? # optional route
  530. (?:
  531. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  532. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  533. |
  534. " (?: # opening quote...
  535. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  536. | # or
  537. \\ [^\x80-\xff] # Escaped something (something != CR)
  538. )* " # closing quote
  539. ) # initial word
  540. (?: (?: [\040\t] | \(
  541. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  542. \) )* \. (?: [\040\t] | \(
  543. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  544. \) )* (?:
  545. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  546. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  547. |
  548. " (?: # opening quote...
  549. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  550. | # or
  551. \\ [^\x80-\xff] # Escaped something (something != CR)
  552. )* " # closing quote
  553. ) )* # further okay, if led by a period
  554. (?: [\040\t] | \(
  555. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  556. \) )* @ (?: [\040\t] | \(
  557. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  558. \) )* (?:
  559. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  560. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  561. | \[ # [
  562. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  563. \] # ]
  564. ) # initial subdomain
  565. (?: #
  566. (?: [\040\t] | \(
  567. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  568. \) )* \. # if led by a period...
  569. (?: [\040\t] | \(
  570. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  571. \) )* (?:
  572. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  573. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  574. | \[ # [
  575. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  576. \] # ]
  577. ) # ...further okay
  578. )*
  579. # address spec
  580. (?: [\040\t] | \(
  581. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  582. \) )* > # trailing >
  583. # name and address
  584. ) (?: [\040\t] | \(
  585. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  586. \) )* # optional trailing comment
  587. /x
  588. Alan Other <user\@dom.ain>
  589. <user\@dom.ain>
  590. user\@dom.ain
  591. \"A. Other\" <user.1234\@dom.ain> (a comment)
  592. A. Other <user.1234\@dom.ain> (a comment)
  593. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  594. A missing angle <user\@some.where
  595. \= Expect no match
  596. The quick brown fox
  597. /[\040\t]* # Nab whitespace.
  598. (?:
  599. \( # (
  600. [^\\\x80-\xff\n\015()] * # normal*
  601. (?: # (
  602. (?: \\ [^\x80-\xff] |
  603. \( # (
  604. [^\\\x80-\xff\n\015()] * # normal*
  605. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  606. \) # )
  607. ) # special
  608. [^\\\x80-\xff\n\015()] * # normal*
  609. )* # )*
  610. \) # )
  611. [\040\t]* )* # If comment found, allow more spaces.
  612. # optional leading comment
  613. (?:
  614. (?:
  615. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  616. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  617. # Atom
  618. | # or
  619. " # "
  620. [^\\\x80-\xff\n\015"] * # normal
  621. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  622. " # "
  623. # Quoted string
  624. )
  625. [\040\t]* # Nab whitespace.
  626. (?:
  627. \( # (
  628. [^\\\x80-\xff\n\015()] * # normal*
  629. (?: # (
  630. (?: \\ [^\x80-\xff] |
  631. \( # (
  632. [^\\\x80-\xff\n\015()] * # normal*
  633. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  634. \) # )
  635. ) # special
  636. [^\\\x80-\xff\n\015()] * # normal*
  637. )* # )*
  638. \) # )
  639. [\040\t]* )* # If comment found, allow more spaces.
  640. (?:
  641. \.
  642. [\040\t]* # Nab whitespace.
  643. (?:
  644. \( # (
  645. [^\\\x80-\xff\n\015()] * # normal*
  646. (?: # (
  647. (?: \\ [^\x80-\xff] |
  648. \( # (
  649. [^\\\x80-\xff\n\015()] * # normal*
  650. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  651. \) # )
  652. ) # special
  653. [^\\\x80-\xff\n\015()] * # normal*
  654. )* # )*
  655. \) # )
  656. [\040\t]* )* # If comment found, allow more spaces.
  657. (?:
  658. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  659. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  660. # Atom
  661. | # or
  662. " # "
  663. [^\\\x80-\xff\n\015"] * # normal
  664. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  665. " # "
  666. # Quoted string
  667. )
  668. [\040\t]* # Nab whitespace.
  669. (?:
  670. \( # (
  671. [^\\\x80-\xff\n\015()] * # normal*
  672. (?: # (
  673. (?: \\ [^\x80-\xff] |
  674. \( # (
  675. [^\\\x80-\xff\n\015()] * # normal*
  676. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  677. \) # )
  678. ) # special
  679. [^\\\x80-\xff\n\015()] * # normal*
  680. )* # )*
  681. \) # )
  682. [\040\t]* )* # If comment found, allow more spaces.
  683. # additional words
  684. )*
  685. @
  686. [\040\t]* # Nab whitespace.
  687. (?:
  688. \( # (
  689. [^\\\x80-\xff\n\015()] * # normal*
  690. (?: # (
  691. (?: \\ [^\x80-\xff] |
  692. \( # (
  693. [^\\\x80-\xff\n\015()] * # normal*
  694. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  695. \) # )
  696. ) # special
  697. [^\\\x80-\xff\n\015()] * # normal*
  698. )* # )*
  699. \) # )
  700. [\040\t]* )* # If comment found, allow more spaces.
  701. (?:
  702. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  703. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  704. |
  705. \[ # [
  706. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  707. \] # ]
  708. )
  709. [\040\t]* # Nab whitespace.
  710. (?:
  711. \( # (
  712. [^\\\x80-\xff\n\015()] * # normal*
  713. (?: # (
  714. (?: \\ [^\x80-\xff] |
  715. \( # (
  716. [^\\\x80-\xff\n\015()] * # normal*
  717. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  718. \) # )
  719. ) # special
  720. [^\\\x80-\xff\n\015()] * # normal*
  721. )* # )*
  722. \) # )
  723. [\040\t]* )* # If comment found, allow more spaces.
  724. # optional trailing comments
  725. (?:
  726. \.
  727. [\040\t]* # Nab whitespace.
  728. (?:
  729. \( # (
  730. [^\\\x80-\xff\n\015()] * # normal*
  731. (?: # (
  732. (?: \\ [^\x80-\xff] |
  733. \( # (
  734. [^\\\x80-\xff\n\015()] * # normal*
  735. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  736. \) # )
  737. ) # special
  738. [^\\\x80-\xff\n\015()] * # normal*
  739. )* # )*
  740. \) # )
  741. [\040\t]* )* # If comment found, allow more spaces.
  742. (?:
  743. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  744. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  745. |
  746. \[ # [
  747. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  748. \] # ]
  749. )
  750. [\040\t]* # Nab whitespace.
  751. (?:
  752. \( # (
  753. [^\\\x80-\xff\n\015()] * # normal*
  754. (?: # (
  755. (?: \\ [^\x80-\xff] |
  756. \( # (
  757. [^\\\x80-\xff\n\015()] * # normal*
  758. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  759. \) # )
  760. ) # special
  761. [^\\\x80-\xff\n\015()] * # normal*
  762. )* # )*
  763. \) # )
  764. [\040\t]* )* # If comment found, allow more spaces.
  765. # optional trailing comments
  766. )*
  767. # address
  768. | # or
  769. (?:
  770. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  771. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  772. # Atom
  773. | # or
  774. " # "
  775. [^\\\x80-\xff\n\015"] * # normal
  776. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  777. " # "
  778. # Quoted string
  779. )
  780. # leading word
  781. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces
  782. (?:
  783. (?:
  784. \( # (
  785. [^\\\x80-\xff\n\015()] * # normal*
  786. (?: # (
  787. (?: \\ [^\x80-\xff] |
  788. \( # (
  789. [^\\\x80-\xff\n\015()] * # normal*
  790. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  791. \) # )
  792. ) # special
  793. [^\\\x80-\xff\n\015()] * # normal*
  794. )* # )*
  795. \) # )
  796. |
  797. " # "
  798. [^\\\x80-\xff\n\015"] * # normal
  799. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  800. " # "
  801. ) # "special" comment or quoted string
  802. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal"
  803. )*
  804. <
  805. [\040\t]* # Nab whitespace.
  806. (?:
  807. \( # (
  808. [^\\\x80-\xff\n\015()] * # normal*
  809. (?: # (
  810. (?: \\ [^\x80-\xff] |
  811. \( # (
  812. [^\\\x80-\xff\n\015()] * # normal*
  813. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  814. \) # )
  815. ) # special
  816. [^\\\x80-\xff\n\015()] * # normal*
  817. )* # )*
  818. \) # )
  819. [\040\t]* )* # If comment found, allow more spaces.
  820. # <
  821. (?:
  822. @
  823. [\040\t]* # Nab whitespace.
  824. (?:
  825. \( # (
  826. [^\\\x80-\xff\n\015()] * # normal*
  827. (?: # (
  828. (?: \\ [^\x80-\xff] |
  829. \( # (
  830. [^\\\x80-\xff\n\015()] * # normal*
  831. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  832. \) # )
  833. ) # special
  834. [^\\\x80-\xff\n\015()] * # normal*
  835. )* # )*
  836. \) # )
  837. [\040\t]* )* # If comment found, allow more spaces.
  838. (?:
  839. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  840. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  841. |
  842. \[ # [
  843. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  844. \] # ]
  845. )
  846. [\040\t]* # Nab whitespace.
  847. (?:
  848. \( # (
  849. [^\\\x80-\xff\n\015()] * # normal*
  850. (?: # (
  851. (?: \\ [^\x80-\xff] |
  852. \( # (
  853. [^\\\x80-\xff\n\015()] * # normal*
  854. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  855. \) # )
  856. ) # special
  857. [^\\\x80-\xff\n\015()] * # normal*
  858. )* # )*
  859. \) # )
  860. [\040\t]* )* # If comment found, allow more spaces.
  861. # optional trailing comments
  862. (?:
  863. \.
  864. [\040\t]* # Nab whitespace.
  865. (?:
  866. \( # (
  867. [^\\\x80-\xff\n\015()] * # normal*
  868. (?: # (
  869. (?: \\ [^\x80-\xff] |
  870. \( # (
  871. [^\\\x80-\xff\n\015()] * # normal*
  872. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  873. \) # )
  874. ) # special
  875. [^\\\x80-\xff\n\015()] * # normal*
  876. )* # )*
  877. \) # )
  878. [\040\t]* )* # If comment found, allow more spaces.
  879. (?:
  880. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  881. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  882. |
  883. \[ # [
  884. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  885. \] # ]
  886. )
  887. [\040\t]* # Nab whitespace.
  888. (?:
  889. \( # (
  890. [^\\\x80-\xff\n\015()] * # normal*
  891. (?: # (
  892. (?: \\ [^\x80-\xff] |
  893. \( # (
  894. [^\\\x80-\xff\n\015()] * # normal*
  895. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  896. \) # )
  897. ) # special
  898. [^\\\x80-\xff\n\015()] * # normal*
  899. )* # )*
  900. \) # )
  901. [\040\t]* )* # If comment found, allow more spaces.
  902. # optional trailing comments
  903. )*
  904. (?: ,
  905. [\040\t]* # Nab whitespace.
  906. (?:
  907. \( # (
  908. [^\\\x80-\xff\n\015()] * # normal*
  909. (?: # (
  910. (?: \\ [^\x80-\xff] |
  911. \( # (
  912. [^\\\x80-\xff\n\015()] * # normal*
  913. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  914. \) # )
  915. ) # special
  916. [^\\\x80-\xff\n\015()] * # normal*
  917. )* # )*
  918. \) # )
  919. [\040\t]* )* # If comment found, allow more spaces.
  920. @
  921. [\040\t]* # Nab whitespace.
  922. (?:
  923. \( # (
  924. [^\\\x80-\xff\n\015()] * # normal*
  925. (?: # (
  926. (?: \\ [^\x80-\xff] |
  927. \( # (
  928. [^\\\x80-\xff\n\015()] * # normal*
  929. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  930. \) # )
  931. ) # special
  932. [^\\\x80-\xff\n\015()] * # normal*
  933. )* # )*
  934. \) # )
  935. [\040\t]* )* # If comment found, allow more spaces.
  936. (?:
  937. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  938. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  939. |
  940. \[ # [
  941. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  942. \] # ]
  943. )
  944. [\040\t]* # Nab whitespace.
  945. (?:
  946. \( # (
  947. [^\\\x80-\xff\n\015()] * # normal*
  948. (?: # (
  949. (?: \\ [^\x80-\xff] |
  950. \( # (
  951. [^\\\x80-\xff\n\015()] * # normal*
  952. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  953. \) # )
  954. ) # special
  955. [^\\\x80-\xff\n\015()] * # normal*
  956. )* # )*
  957. \) # )
  958. [\040\t]* )* # If comment found, allow more spaces.
  959. # optional trailing comments
  960. (?:
  961. \.
  962. [\040\t]* # Nab whitespace.
  963. (?:
  964. \( # (
  965. [^\\\x80-\xff\n\015()] * # normal*
  966. (?: # (
  967. (?: \\ [^\x80-\xff] |
  968. \( # (
  969. [^\\\x80-\xff\n\015()] * # normal*
  970. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  971. \) # )
  972. ) # special
  973. [^\\\x80-\xff\n\015()] * # normal*
  974. )* # )*
  975. \) # )
  976. [\040\t]* )* # If comment found, allow more spaces.
  977. (?:
  978. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  979. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  980. |
  981. \[ # [
  982. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  983. \] # ]
  984. )
  985. [\040\t]* # Nab whitespace.
  986. (?:
  987. \( # (
  988. [^\\\x80-\xff\n\015()] * # normal*
  989. (?: # (
  990. (?: \\ [^\x80-\xff] |
  991. \( # (
  992. [^\\\x80-\xff\n\015()] * # normal*
  993. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  994. \) # )
  995. ) # special
  996. [^\\\x80-\xff\n\015()] * # normal*
  997. )* # )*
  998. \) # )
  999. [\040\t]* )* # If comment found, allow more spaces.
  1000. # optional trailing comments
  1001. )*
  1002. )* # additional domains
  1003. :
  1004. [\040\t]* # Nab whitespace.
  1005. (?:
  1006. \( # (
  1007. [^\\\x80-\xff\n\015()] * # normal*
  1008. (?: # (
  1009. (?: \\ [^\x80-\xff] |
  1010. \( # (
  1011. [^\\\x80-\xff\n\015()] * # normal*
  1012. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1013. \) # )
  1014. ) # special
  1015. [^\\\x80-\xff\n\015()] * # normal*
  1016. )* # )*
  1017. \) # )
  1018. [\040\t]* )* # If comment found, allow more spaces.
  1019. # optional trailing comments
  1020. )? # optional route
  1021. (?:
  1022. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1023. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1024. # Atom
  1025. | # or
  1026. " # "
  1027. [^\\\x80-\xff\n\015"] * # normal
  1028. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1029. " # "
  1030. # Quoted string
  1031. )
  1032. [\040\t]* # Nab whitespace.
  1033. (?:
  1034. \( # (
  1035. [^\\\x80-\xff\n\015()] * # normal*
  1036. (?: # (
  1037. (?: \\ [^\x80-\xff] |
  1038. \( # (
  1039. [^\\\x80-\xff\n\015()] * # normal*
  1040. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1041. \) # )
  1042. ) # special
  1043. [^\\\x80-\xff\n\015()] * # normal*
  1044. )* # )*
  1045. \) # )
  1046. [\040\t]* )* # If comment found, allow more spaces.
  1047. (?:
  1048. \.
  1049. [\040\t]* # Nab whitespace.
  1050. (?:
  1051. \( # (
  1052. [^\\\x80-\xff\n\015()] * # normal*
  1053. (?: # (
  1054. (?: \\ [^\x80-\xff] |
  1055. \( # (
  1056. [^\\\x80-\xff\n\015()] * # normal*
  1057. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1058. \) # )
  1059. ) # special
  1060. [^\\\x80-\xff\n\015()] * # normal*
  1061. )* # )*
  1062. \) # )
  1063. [\040\t]* )* # If comment found, allow more spaces.
  1064. (?:
  1065. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1066. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1067. # Atom
  1068. | # or
  1069. " # "
  1070. [^\\\x80-\xff\n\015"] * # normal
  1071. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1072. " # "
  1073. # Quoted string
  1074. )
  1075. [\040\t]* # Nab whitespace.
  1076. (?:
  1077. \( # (
  1078. [^\\\x80-\xff\n\015()] * # normal*
  1079. (?: # (
  1080. (?: \\ [^\x80-\xff] |
  1081. \( # (
  1082. [^\\\x80-\xff\n\015()] * # normal*
  1083. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1084. \) # )
  1085. ) # special
  1086. [^\\\x80-\xff\n\015()] * # normal*
  1087. )* # )*
  1088. \) # )
  1089. [\040\t]* )* # If comment found, allow more spaces.
  1090. # additional words
  1091. )*
  1092. @
  1093. [\040\t]* # Nab whitespace.
  1094. (?:
  1095. \( # (
  1096. [^\\\x80-\xff\n\015()] * # normal*
  1097. (?: # (
  1098. (?: \\ [^\x80-\xff] |
  1099. \( # (
  1100. [^\\\x80-\xff\n\015()] * # normal*
  1101. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1102. \) # )
  1103. ) # special
  1104. [^\\\x80-\xff\n\015()] * # normal*
  1105. )* # )*
  1106. \) # )
  1107. [\040\t]* )* # If comment found, allow more spaces.
  1108. (?:
  1109. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1110. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1111. |
  1112. \[ # [
  1113. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1114. \] # ]
  1115. )
  1116. [\040\t]* # Nab whitespace.
  1117. (?:
  1118. \( # (
  1119. [^\\\x80-\xff\n\015()] * # normal*
  1120. (?: # (
  1121. (?: \\ [^\x80-\xff] |
  1122. \( # (
  1123. [^\\\x80-\xff\n\015()] * # normal*
  1124. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1125. \) # )
  1126. ) # special
  1127. [^\\\x80-\xff\n\015()] * # normal*
  1128. )* # )*
  1129. \) # )
  1130. [\040\t]* )* # If comment found, allow more spaces.
  1131. # optional trailing comments
  1132. (?:
  1133. \.
  1134. [\040\t]* # Nab whitespace.
  1135. (?:
  1136. \( # (
  1137. [^\\\x80-\xff\n\015()] * # normal*
  1138. (?: # (
  1139. (?: \\ [^\x80-\xff] |
  1140. \( # (
  1141. [^\\\x80-\xff\n\015()] * # normal*
  1142. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1143. \) # )
  1144. ) # special
  1145. [^\\\x80-\xff\n\015()] * # normal*
  1146. )* # )*
  1147. \) # )
  1148. [\040\t]* )* # If comment found, allow more spaces.
  1149. (?:
  1150. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1151. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1152. |
  1153. \[ # [
  1154. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1155. \] # ]
  1156. )
  1157. [\040\t]* # Nab whitespace.
  1158. (?:
  1159. \( # (
  1160. [^\\\x80-\xff\n\015()] * # normal*
  1161. (?: # (
  1162. (?: \\ [^\x80-\xff] |
  1163. \( # (
  1164. [^\\\x80-\xff\n\015()] * # normal*
  1165. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1166. \) # )
  1167. ) # special
  1168. [^\\\x80-\xff\n\015()] * # normal*
  1169. )* # )*
  1170. \) # )
  1171. [\040\t]* )* # If comment found, allow more spaces.
  1172. # optional trailing comments
  1173. )*
  1174. # address spec
  1175. > # >
  1176. # name and address
  1177. )
  1178. /x
  1179. Alan Other <user\@dom.ain>
  1180. <user\@dom.ain>
  1181. user\@dom.ain
  1182. \"A. Other\" <user.1234\@dom.ain> (a comment)
  1183. A. Other <user.1234\@dom.ain> (a comment)
  1184. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  1185. A missing angle <user\@some.where
  1186. \= Expect no match
  1187. The quick brown fox
  1188. /abc\0def\00pqr\000xyz\0000AB/
  1189. abc\0def\00pqr\000xyz\0000AB
  1190. abc456 abc\0def\00pqr\000xyz\0000ABCDE
  1191. /abc\x0def\x00pqr\x000xyz\x0000AB/
  1192. abc\x0def\x00pqr\x000xyz\x0000AB
  1193. abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
  1194. /^[\000-\037]/
  1195. \0A
  1196. \01B
  1197. \037C
  1198. /\0*/
  1199. \0\0\0\0
  1200. /A\x0{2,3}Z/
  1201. The A\x0\x0Z
  1202. An A\0\x0\0Z
  1203. \= Expect no match
  1204. A\0Z
  1205. A\0\x0\0\x0Z
  1206. /^(cow|)\1(bell)/
  1207. cowcowbell
  1208. bell
  1209. \= Expect no match
  1210. cowbell
  1211. /^\s/
  1212. \040abc
  1213. \x0cabc
  1214. \nabc
  1215. \rabc
  1216. \tabc
  1217. \= Expect no match
  1218. abc
  1219. /^a b
  1220. c/x
  1221. abc
  1222. /^(a|)\1*b/
  1223. ab
  1224. aaaab
  1225. b
  1226. \= Expect no match
  1227. acb
  1228. /^(a|)\1+b/
  1229. aab
  1230. aaaab
  1231. b
  1232. \= Expect no match
  1233. ab
  1234. /^(a|)\1?b/
  1235. ab
  1236. aab
  1237. b
  1238. \= Expect no match
  1239. acb
  1240. /^(a|)\1{2}b/
  1241. aaab
  1242. b
  1243. \= Expect no match
  1244. ab
  1245. aab
  1246. aaaab
  1247. /^(a|)\1{2,3}b/
  1248. aaab
  1249. aaaab
  1250. b
  1251. \= Expect no match
  1252. ab
  1253. aab
  1254. aaaaab
  1255. /ab{1,3}bc/
  1256. abbbbc
  1257. abbbc
  1258. abbc
  1259. \= Expect no match
  1260. abc
  1261. abbbbbc
  1262. /([^.]*)\.([^:]*):[T ]+(.*)/
  1263. track1.title:TBlah blah blah
  1264. /([^.]*)\.([^:]*):[T ]+(.*)/i
  1265. track1.title:TBlah blah blah
  1266. /([^.]*)\.([^:]*):[t ]+(.*)/i
  1267. track1.title:TBlah blah blah
  1268. /^[W-c]+$/
  1269. WXY_^abc
  1270. \= Expect no match
  1271. wxy
  1272. /^[W-c]+$/i
  1273. WXY_^abc
  1274. wxy_^ABC
  1275. /^[\x3f-\x5F]+$/i
  1276. WXY_^abc
  1277. wxy_^ABC
  1278. /^abc$/m
  1279. abc
  1280. qqq\nabc
  1281. abc\nzzz
  1282. qqq\nabc\nzzz
  1283. /^abc$/
  1284. abc
  1285. \= Expect no match
  1286. qqq\nabc
  1287. abc\nzzz
  1288. qqq\nabc\nzzz
  1289. /\Aabc\Z/m
  1290. abc
  1291. abc\n
  1292. \= Expect no match
  1293. qqq\nabc
  1294. abc\nzzz
  1295. qqq\nabc\nzzz
  1296. /\A(.)*\Z/s
  1297. abc\ndef
  1298. /\A(.)*\Z/m
  1299. \= Expect no match
  1300. abc\ndef
  1301. /(?:b)|(?::+)/
  1302. b::c
  1303. c::b
  1304. /[-az]+/
  1305. az-
  1306. \= Expect no match
  1307. b
  1308. /[az-]+/
  1309. za-
  1310. \= Expect no match
  1311. b
  1312. /[a\-z]+/
  1313. a-z
  1314. \= Expect no match
  1315. b
  1316. /[a-z]+/
  1317. abcdxyz
  1318. /[\d-]+/
  1319. 12-34
  1320. \= Expect no match
  1321. aaa
  1322. /\x5c/
  1323. \\
  1324. /\x20Z/
  1325. the Zoo
  1326. \= Expect no match
  1327. Zulu
  1328. /(abc)\1/i
  1329. abcabc
  1330. ABCabc
  1331. abcABC
  1332. /abc$/
  1333. abc
  1334. abc\n
  1335. \= Expect no match
  1336. abc\ndef
  1337. /(abc)\123/
  1338. abc\x53
  1339. /(abc)\223/
  1340. abc\x93
  1341. /(abc)\323/
  1342. abc\xd3
  1343. /(abc)\100/
  1344. abc\x40
  1345. abc\100
  1346. /(abc)\1000/
  1347. abc\x400
  1348. abc\x40\x30
  1349. abc\1000
  1350. abc\100\x30
  1351. abc\100\060
  1352. abc\100\60
  1353. /^(A)(B)(C)(D)(E)(F)(G)(H)(I)\8\9$/
  1354. ABCDEFGHIHI
  1355. /^[A\8B\9C]+$/
  1356. A8B9C
  1357. \= Expect no match
  1358. A8B9C\x00
  1359. /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
  1360. abcdefghijkllS
  1361. /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
  1362. abcdefghijk\12S
  1363. /a{0}bc/
  1364. bc
  1365. /(a|(bc)){0,0}?xyz/
  1366. xyz
  1367. /abc[\10]de/
  1368. abc\010de
  1369. /abc[\1]de/
  1370. abc\1de
  1371. /(abc)[\1]de/
  1372. abc\1de
  1373. /(?s)a.b/
  1374. a\nb
  1375. /^([^a])([^\b])([^c]*)([^d]{3,4})/
  1376. baNOTccccd
  1377. baNOTcccd
  1378. baNOTccd
  1379. bacccd
  1380. \= Expect no match
  1381. anything
  1382. b\bc
  1383. baccd
  1384. /[^a]/
  1385. Abc
  1386. /[^a]/i
  1387. Abc
  1388. /[^a]+/
  1389. AAAaAbc
  1390. /[^a]+/i
  1391. AAAaAbc
  1392. /[^a]+/
  1393. bbb\nccc
  1394. /[^k]$/
  1395. abc
  1396. \= Expect no match
  1397. abk
  1398. /[^k]{2,3}$/
  1399. abc
  1400. kbc
  1401. kabc
  1402. \= Expect no match
  1403. abk
  1404. akb
  1405. akk
  1406. /^\d{8,}\@.+[^k]$/
  1407. 12345678\@a.b.c.d
  1408. 123456789\@x.y.z
  1409. \= Expect no match
  1410. 12345678\@x.y.uk
  1411. 1234567\@a.b.c.d
  1412. /(a)\1{8,}/
  1413. aaaaaaaaa
  1414. aaaaaaaaaa
  1415. \= Expect no match
  1416. aaaaaaa
  1417. /[^a]/
  1418. aaaabcd
  1419. aaAabcd
  1420. /[^a]/i
  1421. aaaabcd
  1422. aaAabcd
  1423. /[^az]/
  1424. aaaabcd
  1425. aaAabcd
  1426. /[^az]/i
  1427. aaaabcd
  1428. aaAabcd
  1429. /\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
  1430. \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
  1431. /P[^*]TAIRE[^*]{1,6}?LL/
  1432. xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
  1433. /P[^*]TAIRE[^*]{1,}?LL/
  1434. xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
  1435. /(\.\d\d[1-9]?)\d+/
  1436. 1.230003938
  1437. 1.875000282
  1438. 1.235
  1439. /(\.\d\d((?=0)|\d(?=\d)))/
  1440. 1.230003938
  1441. 1.875000282
  1442. \= Expect no match
  1443. 1.235
  1444. /a(?)b/
  1445. ab
  1446. /\b(foo)\s+(\w+)/i
  1447. Food is on the foo table
  1448. /foo(.*)bar/
  1449. The food is under the bar in the barn.
  1450. /foo(.*?)bar/
  1451. The food is under the bar in the barn.
  1452. /(.*)(\d*)/
  1453. I have 2 numbers: 53147
  1454. /(.*)(\d+)/
  1455. I have 2 numbers: 53147
  1456. /(.*?)(\d*)/
  1457. I have 2 numbers: 53147
  1458. /(.*?)(\d+)/
  1459. I have 2 numbers: 53147
  1460. /(.*)(\d+)$/
  1461. I have 2 numbers: 53147
  1462. /(.*?)(\d+)$/
  1463. I have 2 numbers: 53147
  1464. /(.*)\b(\d+)$/
  1465. I have 2 numbers: 53147
  1466. /(.*\D)(\d+)$/
  1467. I have 2 numbers: 53147
  1468. /^\D*(?!123)/
  1469. ABC123
  1470. /^(\D*)(?=\d)(?!123)/
  1471. ABC445
  1472. \= Expect no match
  1473. ABC123
  1474. /^[W-]46]/
  1475. W46]789
  1476. -46]789
  1477. \= Expect no match
  1478. Wall
  1479. Zebra
  1480. 42
  1481. [abcd]
  1482. ]abcd[
  1483. /^[W-\]46]/
  1484. W46]789
  1485. Wall
  1486. Zebra
  1487. Xylophone
  1488. 42
  1489. [abcd]
  1490. ]abcd[
  1491. \\backslash
  1492. \= Expect no match
  1493. -46]789
  1494. well
  1495. /\d\d\/\d\d\/\d\d\d\d/
  1496. 01/01/2000
  1497. /word (?:[a-zA-Z0-9]+ ){0,10}otherword/
  1498. word cat dog elephant mussel cow horse canary baboon snake shark otherword
  1499. \= Expect no match
  1500. word cat dog elephant mussel cow horse canary baboon snake shark
  1501. /word (?:[a-zA-Z0-9]+ ){0,300}otherword/
  1502. \= Expect no match
  1503. word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
  1504. /^(a){0,0}/
  1505. bcd
  1506. abc
  1507. aab
  1508. /^(a){0,1}/
  1509. bcd
  1510. abc
  1511. aab
  1512. /^(a){0,2}/
  1513. bcd
  1514. abc
  1515. aab
  1516. /^(a){0,3}/
  1517. bcd
  1518. abc
  1519. aab
  1520. aaa
  1521. /^(a){0,}/
  1522. bcd
  1523. abc
  1524. aab
  1525. aaa
  1526. aaaaaaaa
  1527. /^(a){1,1}/
  1528. abc
  1529. aab
  1530. \= Expect no match
  1531. bcd
  1532. /^(a){1,2}/
  1533. abc
  1534. aab
  1535. \= Expect no match
  1536. bcd
  1537. /^(a){1,3}/
  1538. abc
  1539. aab
  1540. aaa
  1541. \= Expect no match
  1542. bcd
  1543. /^(a){1,}/
  1544. abc
  1545. aab
  1546. aaa
  1547. aaaaaaaa
  1548. \= Expect no match
  1549. bcd
  1550. /.*\.gif/
  1551. borfle\nbib.gif\nno
  1552. /.{0,}\.gif/
  1553. borfle\nbib.gif\nno
  1554. /.*\.gif/m
  1555. borfle\nbib.gif\nno
  1556. /.*\.gif/s
  1557. borfle\nbib.gif\nno
  1558. /.*\.gif/ms
  1559. borfle\nbib.gif\nno
  1560. /.*$/
  1561. borfle\nbib.gif\nno
  1562. /.*$/m
  1563. borfle\nbib.gif\nno
  1564. /.*$/s
  1565. borfle\nbib.gif\nno
  1566. /.*$/ms
  1567. borfle\nbib.gif\nno
  1568. /.*$/
  1569. borfle\nbib.gif\nno\n
  1570. /.*$/m
  1571. borfle\nbib.gif\nno\n
  1572. /.*$/s
  1573. borfle\nbib.gif\nno\n
  1574. /.*$/ms
  1575. borfle\nbib.gif\nno\n
  1576. /(.*X|^B)/
  1577. abcde\n1234Xyz
  1578. BarFoo
  1579. \= Expect no match
  1580. abcde\nBar
  1581. /(.*X|^B)/m
  1582. abcde\n1234Xyz
  1583. BarFoo
  1584. abcde\nBar
  1585. /(.*X|^B)/s
  1586. abcde\n1234Xyz
  1587. BarFoo
  1588. \= Expect no match
  1589. abcde\nBar
  1590. /(.*X|^B)/ms
  1591. abcde\n1234Xyz
  1592. BarFoo
  1593. abcde\nBar
  1594. /(?s)(.*X|^B)/
  1595. abcde\n1234Xyz
  1596. BarFoo
  1597. \= Expect no match
  1598. abcde\nBar
  1599. /(?s:.*X|^B)/
  1600. abcde\n1234Xyz
  1601. BarFoo
  1602. \= Expect no match
  1603. abcde\nBar
  1604. /^.*B/
  1605. \= Expect no match
  1606. abc\nB
  1607. /(?s)^.*B/
  1608. abc\nB
  1609. /(?m)^.*B/
  1610. abc\nB
  1611. /(?ms)^.*B/
  1612. abc\nB
  1613. /(?ms)^B/
  1614. abc\nB
  1615. /(?s)B$/
  1616. B\n
  1617. /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
  1618. 123456654321
  1619. /^\d\d\d\d\d\d\d\d\d\d\d\d/
  1620. 123456654321
  1621. /^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
  1622. 123456654321
  1623. /^[abc]{12}/
  1624. abcabcabcabc
  1625. /^[a-c]{12}/
  1626. abcabcabcabc
  1627. /^(a|b|c){12}/
  1628. abcabcabcabc
  1629. /^[abcdefghijklmnopqrstuvwxy0123456789]/
  1630. n
  1631. \= Expect no match
  1632. z
  1633. /abcde{0,0}/
  1634. abcd
  1635. \= Expect no match
  1636. abce
  1637. /ab[cd]{0,0}e/
  1638. abe
  1639. \= Expect no match
  1640. abcde
  1641. /ab(c){0,0}d/
  1642. abd
  1643. \= Expect no match
  1644. abcd
  1645. /a(b*)/
  1646. a
  1647. ab
  1648. abbbb
  1649. \= Expect no match
  1650. bbbbb
  1651. /ab\d{0}e/
  1652. abe
  1653. \= Expect no match
  1654. ab1e
  1655. /"([^\\"]+|\\.)*"/
  1656. the \"quick\" brown fox
  1657. \"the \\\"quick\\\" brown fox\"
  1658. /.*?/g,aftertext
  1659. abc
  1660. /\b/g,aftertext
  1661. abc
  1662. /\b/g,aftertext
  1663. abc
  1664. //g
  1665. abc
  1666. /<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
  1667. <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
  1668. /a[^a]b/
  1669. acb
  1670. a\nb
  1671. /a.b/
  1672. acb
  1673. \= Expect no match
  1674. a\nb
  1675. /a[^a]b/s
  1676. acb
  1677. a\nb
  1678. /a.b/s
  1679. acb
  1680. a\nb
  1681. /^(b+?|a){1,2}?c/
  1682. bac
  1683. bbac
  1684. bbbac
  1685. bbbbac
  1686. bbbbbac
  1687. /^(b+|a){1,2}?c/
  1688. bac
  1689. bbac
  1690. bbbac
  1691. bbbbac
  1692. bbbbbac
  1693. /(?!\A)x/m
  1694. a\bx\n
  1695. a\nx\n
  1696. \= Expect no match
  1697. x\nb\n
  1698. /(A|B)*?CD/
  1699. CD
  1700. /(A|B)*CD/
  1701. CD
  1702. /(AB)*?\1/
  1703. ABABAB
  1704. /(AB)*\1/
  1705. ABABAB
  1706. /(?<!bar)foo/
  1707. foo
  1708. catfood
  1709. arfootle
  1710. rfoosh
  1711. \= Expect no match
  1712. barfoo
  1713. towbarfoo
  1714. /\w{3}(?<!bar)foo/
  1715. catfood
  1716. \= Expect no match
  1717. foo
  1718. barfoo
  1719. towbarfoo
  1720. /(?<=(foo)a)bar/
  1721. fooabar
  1722. \= Expect no match
  1723. bar
  1724. foobbar
  1725. /\Aabc\z/m
  1726. abc
  1727. \= Expect no match
  1728. abc\n
  1729. qqq\nabc
  1730. abc\nzzz
  1731. qqq\nabc\nzzz
  1732. /(?>.*\/)foo/
  1733. /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
  1734. \= Expect no match
  1735. /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
  1736. /(?>(\.\d\d[1-9]?))\d+/
  1737. 1.230003938
  1738. 1.875000282
  1739. \= Expect no match
  1740. 1.235
  1741. /^((?>\w+)|(?>\s+))*$/
  1742. now is the time for all good men to come to the aid of the party
  1743. \= Expect no match
  1744. this is not a line with only words and spaces!
  1745. /(\d+)(\w)/
  1746. 12345a
  1747. 12345+
  1748. /((?>\d+))(\w)/
  1749. 12345a
  1750. \= Expect no match
  1751. 12345+
  1752. /(?>a+)b/
  1753. aaab
  1754. /((?>a+)b)/
  1755. aaab
  1756. /(?>(a+))b/
  1757. aaab
  1758. /(?>b)+/
  1759. aaabbbccc
  1760. /(?>a+|b+|c+)*c/
  1761. aaabbbbccccd
  1762. /((?>[^()]+)|\([^()]*\))+/
  1763. ((abc(ade)ufh()()x
  1764. /\(((?>[^()]+)|\([^()]+\))+\)/
  1765. (abc)
  1766. (abc(def)xyz)
  1767. \= Expect no match
  1768. ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  1769. /a(?-i)b/i
  1770. ab
  1771. Ab
  1772. \= Expect no match
  1773. aB
  1774. AB
  1775. /(a (?x)b c)d e/
  1776. a bcd e
  1777. \= Expect no match
  1778. a b cd e
  1779. abcd e
  1780. a bcde
  1781. /(a b(?x)c d (?-x)e f)/
  1782. a bcde f
  1783. \= Expect no match
  1784. abcdef
  1785. /(a(?i)b)c/
  1786. abc
  1787. aBc
  1788. \= Expect no match
  1789. abC
  1790. aBC
  1791. Abc
  1792. ABc
  1793. ABC
  1794. AbC
  1795. /a(?i:b)c/
  1796. abc
  1797. aBc
  1798. \= Expect no match
  1799. ABC
  1800. abC
  1801. aBC
  1802. /a(?i:b)*c/
  1803. aBc
  1804. aBBc
  1805. \= Expect no match
  1806. aBC
  1807. aBBC
  1808. /a(?=b(?i)c)\w\wd/
  1809. abcd
  1810. abCd
  1811. \= Expect no match
  1812. aBCd
  1813. abcD
  1814. /(?s-i:more.*than).*million/i
  1815. more than million
  1816. more than MILLION
  1817. more \n than Million
  1818. \= Expect no match
  1819. MORE THAN MILLION
  1820. more \n than \n million
  1821. /(?:(?s-i)more.*than).*million/i
  1822. more than million
  1823. more than MILLION
  1824. more \n than Million
  1825. \= Expect no match
  1826. MORE THAN MILLION
  1827. more \n than \n million
  1828. /(?>a(?i)b+)+c/
  1829. abc
  1830. aBbc
  1831. aBBc
  1832. \= Expect no match
  1833. Abc
  1834. abAb
  1835. abbC
  1836. /(?=a(?i)b)\w\wc/
  1837. abc
  1838. aBc
  1839. \= Expect no match
  1840. Ab
  1841. abC
  1842. aBC
  1843. /(?<=a(?i)b)(\w\w)c/
  1844. abxxc
  1845. aBxxc
  1846. \= Expect no match
  1847. Abxxc
  1848. ABxxc
  1849. abxxC
  1850. /(?:(a)|b)(?(1)A|B)/
  1851. aA
  1852. bB
  1853. \= Expect no match
  1854. aB
  1855. bA
  1856. /^(a)?(?(1)a|b)+$/
  1857. aa
  1858. b
  1859. bb
  1860. \= Expect no match
  1861. ab
  1862. # Perl gets this next one wrong if the pattern ends with $; in that case it
  1863. # fails to match "12".
  1864. /^(?(?=abc)\w{3}:|\d\d)/
  1865. abc:
  1866. 12
  1867. 123
  1868. \= Expect no match
  1869. xyz
  1870. /^(?(?!abc)\d\d|\w{3}:)$/
  1871. abc:
  1872. 12
  1873. \= Expect no match
  1874. 123
  1875. xyz
  1876. /(?(?<=foo)bar|cat)/
  1877. foobar
  1878. cat
  1879. fcat
  1880. focat
  1881. \= Expect no match
  1882. foocat
  1883. /(?(?<!foo)cat|bar)/
  1884. foobar
  1885. cat
  1886. fcat
  1887. focat
  1888. \= Expect no match
  1889. foocat
  1890. /( \( )? [^()]+ (?(1) \) |) /x
  1891. abcd
  1892. (abcd)
  1893. the quick (abcd) fox
  1894. (abcd
  1895. /( \( )? [^()]+ (?(1) \) ) /x
  1896. abcd
  1897. (abcd)
  1898. the quick (abcd) fox
  1899. (abcd
  1900. /^(?(2)a|(1)(2))+$/
  1901. 12
  1902. 12a
  1903. 12aa
  1904. \= Expect no match
  1905. 1234
  1906. /((?i)blah)\s+\1/
  1907. blah blah
  1908. BLAH BLAH
  1909. Blah Blah
  1910. blaH blaH
  1911. \= Expect no match
  1912. blah BLAH
  1913. Blah blah
  1914. blaH blah
  1915. /((?i)blah)\s+(?i:\1)/
  1916. blah blah
  1917. BLAH BLAH
  1918. Blah Blah
  1919. blaH blaH
  1920. blah BLAH
  1921. Blah blah
  1922. blaH blah
  1923. /((?i)blah)\s+(?m)A(?i:\1)/
  1924. blah ABLAH
  1925. \= Expect no match
  1926. blah aBLAH
  1927. /(?>a*)*/
  1928. a
  1929. aa
  1930. aaaa
  1931. /(abc|)+/
  1932. abc
  1933. abcabc
  1934. abcabcabc
  1935. xyz
  1936. /([a]*)*/
  1937. a
  1938. aaaaa
  1939. /([ab]*)*/
  1940. a
  1941. b
  1942. ababab
  1943. aaaabcde
  1944. bbbb
  1945. /([^a]*)*/
  1946. b
  1947. bbbb
  1948. aaa
  1949. /([^ab]*)*/
  1950. cccc
  1951. abab
  1952. /([a]*?)*/
  1953. a
  1954. aaaa
  1955. /([ab]*?)*/
  1956. a
  1957. b
  1958. abab
  1959. baba
  1960. /([^a]*?)*/
  1961. b
  1962. bbbb
  1963. aaa
  1964. /([^ab]*?)*/
  1965. c
  1966. cccc
  1967. baba
  1968. /(?>a*)*/
  1969. a
  1970. aaabcde
  1971. /((?>a*))*/
  1972. aaaaa
  1973. aabbaa
  1974. /((?>a*?))*/
  1975. aaaaa
  1976. aabbaa
  1977. /(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
  1978. 12-sep-98
  1979. 12-09-98
  1980. \= Expect no match
  1981. sep-12-98
  1982. /(?<=(foo))bar\1/
  1983. foobarfoo
  1984. foobarfootling
  1985. \= Expect no match
  1986. foobar
  1987. barfoo
  1988. /(?i:saturday|sunday)/
  1989. saturday
  1990. sunday
  1991. Saturday
  1992. Sunday
  1993. SATURDAY
  1994. SUNDAY
  1995. SunDay
  1996. /(a(?i)bc|BB)x/
  1997. abcx
  1998. aBCx
  1999. bbx
  2000. BBx
  2001. \= Expect no match
  2002. abcX
  2003. aBCX
  2004. bbX
  2005. BBX
  2006. /^([ab](?i)[cd]|[ef])/
  2007. ac
  2008. aC
  2009. bD
  2010. elephant
  2011. Europe
  2012. frog
  2013. France
  2014. \= Expect no match
  2015. Africa
  2016. /^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
  2017. ab
  2018. aBd
  2019. xy
  2020. xY
  2021. zebra
  2022. Zambesi
  2023. \= Expect no match
  2024. aCD
  2025. XY
  2026. /(?<=foo\n)^bar/m
  2027. foo\nbar
  2028. \= Expect no match
  2029. bar
  2030. baz\nbar
  2031. /(?<=(?<!foo)bar)baz/
  2032. barbaz
  2033. barbarbaz
  2034. koobarbaz
  2035. \= Expect no match
  2036. baz
  2037. foobarbaz
  2038. # The cases of aaaa and aaaaaa are missed out below because Perl does things
  2039. # differently. We know that odd, and maybe incorrect, things happen with
  2040. # recursive references in Perl, as far as 5.11.3 - see some stuff in test #2.
  2041. /^(a\1?){4}$/
  2042. aaaaa
  2043. aaaaaaa
  2044. aaaaaaaaaa
  2045. \= Expect no match
  2046. a
  2047. aa
  2048. aaa
  2049. aaaaaaaa
  2050. aaaaaaaaa
  2051. aaaaaaaaaaa
  2052. aaaaaaaaaaaa
  2053. aaaaaaaaaaaaa
  2054. aaaaaaaaaaaaaa
  2055. aaaaaaaaaaaaaaa
  2056. aaaaaaaaaaaaaaaa
  2057. /^(a\1?)(a\1?)(a\2?)(a\3?)$/
  2058. aaaa
  2059. aaaaa
  2060. aaaaaa
  2061. aaaaaaa
  2062. aaaaaaaaaa
  2063. \= Expect no match
  2064. a
  2065. aa
  2066. aaa
  2067. aaaaaaaa
  2068. aaaaaaaaa
  2069. aaaaaaaaaaa
  2070. aaaaaaaaaaaa
  2071. aaaaaaaaaaaaa
  2072. aaaaaaaaaaaaaa
  2073. aaaaaaaaaaaaaaa
  2074. aaaaaaaaaaaaaaaa
  2075. # The following tests are taken from the Perl 5.005 test suite; some of them
  2076. # are compatible with 5.004, but I'd rather not have to sort them out.
  2077. /abc/
  2078. abc
  2079. xabcy
  2080. ababc
  2081. \= Expect no match
  2082. xbc
  2083. axc
  2084. abx
  2085. /ab*c/
  2086. abc
  2087. /ab*bc/
  2088. abc
  2089. abbc
  2090. abbbbc
  2091. /.{1}/
  2092. abbbbc
  2093. /.{3,4}/
  2094. abbbbc
  2095. /ab{0,}bc/
  2096. abbbbc
  2097. /ab+bc/
  2098. abbc
  2099. \= Expect no match
  2100. abc
  2101. abq
  2102. /ab{1,}bc/
  2103. /ab+bc/
  2104. abbbbc
  2105. /ab{1,}bc/
  2106. abbbbc
  2107. /ab{1,3}bc/
  2108. abbbbc
  2109. /ab{3,4}bc/
  2110. abbbbc
  2111. /ab{4,5}bc/
  2112. \= Expect no match
  2113. abq
  2114. abbbbc
  2115. /ab?bc/
  2116. abbc
  2117. abc
  2118. /ab{0,1}bc/
  2119. abc
  2120. /ab?bc/
  2121. /ab?c/
  2122. abc
  2123. /ab{0,1}c/
  2124. abc
  2125. /^abc$/
  2126. abc
  2127. \= Expect no match
  2128. abbbbc
  2129. abcc
  2130. /^abc/
  2131. abcc
  2132. /^abc$/
  2133. /abc$/
  2134. aabc
  2135. \= Expect no match
  2136. aabcd
  2137. /^/
  2138. abc
  2139. /$/
  2140. abc
  2141. /a.c/
  2142. abc
  2143. axc
  2144. /a.*c/
  2145. axyzc
  2146. /a[bc]d/
  2147. abd
  2148. \= Expect no match
  2149. axyzd
  2150. abc
  2151. /a[b-d]e/
  2152. ace
  2153. /a[b-d]/
  2154. aac
  2155. /a[-b]/
  2156. a-
  2157. /a[b-]/
  2158. a-
  2159. /a]/
  2160. a]
  2161. /a[]]b/
  2162. a]b
  2163. /a[^bc]d/
  2164. aed
  2165. \= Expect no match
  2166. abd
  2167. abd
  2168. /a[^-b]c/
  2169. adc
  2170. /a[^]b]c/
  2171. adc
  2172. a-c
  2173. \= Expect no match
  2174. a]c
  2175. /\ba\b/
  2176. a-
  2177. -a
  2178. -a-
  2179. /\by\b/
  2180. \= Expect no match
  2181. xy
  2182. yz
  2183. xyz
  2184. /\Ba\B/
  2185. \= Expect no match
  2186. a-
  2187. -a
  2188. -a-
  2189. /\By\b/
  2190. xy
  2191. /\by\B/
  2192. yz
  2193. /\By\B/
  2194. xyz
  2195. /\w/
  2196. a
  2197. /\W/
  2198. -
  2199. \= Expect no match
  2200. a
  2201. /a\sb/
  2202. a b
  2203. /a\Sb/
  2204. a-b
  2205. \= Expect no match
  2206. a b
  2207. /\d/
  2208. 1
  2209. /\D/
  2210. -
  2211. \= Expect no match
  2212. 1
  2213. /[\w]/
  2214. a
  2215. /[\W]/
  2216. -
  2217. \= Expect no match
  2218. a
  2219. /a[\s]b/
  2220. a b
  2221. /a[\S]b/
  2222. a-b
  2223. \= Expect no match
  2224. a b
  2225. /[\d]/
  2226. 1
  2227. /[\D]/
  2228. -
  2229. \= Expect no match
  2230. 1
  2231. /ab|cd/
  2232. abc
  2233. abcd
  2234. /()ef/
  2235. def
  2236. /$b/
  2237. /a\(b/
  2238. a(b
  2239. /a\(*b/
  2240. ab
  2241. a((b
  2242. /a\\b/
  2243. a\\b
  2244. /((a))/
  2245. abc
  2246. /(a)b(c)/
  2247. abc
  2248. /a+b+c/
  2249. aabbabc
  2250. /a{1,}b{1,}c/
  2251. aabbabc
  2252. /a.+?c/
  2253. abcabc
  2254. /(a+|b)*/
  2255. ab
  2256. /(a+|b){0,}/
  2257. ab
  2258. /(a+|b)+/
  2259. ab
  2260. /(a+|b){1,}/
  2261. ab
  2262. /(a+|b)?/
  2263. ab
  2264. /(a+|b){0,1}/
  2265. ab
  2266. /[^ab]*/
  2267. cde
  2268. /abc/
  2269. \= Expect no match
  2270. b
  2271. /a*/
  2272. \
  2273. /([abc])*d/
  2274. abbbcd
  2275. /([abc])*bcd/
  2276. abcd
  2277. /a|b|c|d|e/
  2278. e
  2279. /(a|b|c|d|e)f/
  2280. ef
  2281. /abcd*efg/
  2282. abcdefg
  2283. /ab*/
  2284. xabyabbbz
  2285. xayabbbz
  2286. /(ab|cd)e/
  2287. abcde
  2288. /[abhgefdc]ij/
  2289. hij
  2290. /^(ab|cd)e/
  2291. /(abc|)ef/
  2292. abcdef
  2293. /(a|b)c*d/
  2294. abcd
  2295. /(ab|ab*)bc/
  2296. abc
  2297. /a([bc]*)c*/
  2298. abc
  2299. /a([bc]*)(c*d)/
  2300. abcd
  2301. /a([bc]+)(c*d)/
  2302. abcd
  2303. /a([bc]*)(c+d)/
  2304. abcd
  2305. /a[bcd]*dcdcde/
  2306. adcdcde
  2307. /a[bcd]+dcdcde/
  2308. \= Expect no match
  2309. abcde
  2310. adcdcde
  2311. /(ab|a)b*c/
  2312. abc
  2313. /((a)(b)c)(d)/
  2314. abcd
  2315. /[a-zA-Z_][a-zA-Z0-9_]*/
  2316. alpha
  2317. /^a(bc+|b[eh])g|.h$/
  2318. abh
  2319. /(bc+d$|ef*g.|h?i(j|k))/
  2320. effgz
  2321. ij
  2322. reffgz
  2323. \= Expect no match
  2324. effg
  2325. bcdd
  2326. /((((((((((a))))))))))/
  2327. a
  2328. /((((((((((a))))))))))\10/
  2329. aa
  2330. /(((((((((a)))))))))/
  2331. a
  2332. /multiple words of text/
  2333. \= Expect no match
  2334. aa
  2335. uh-uh
  2336. /multiple words/
  2337. multiple words, yeah
  2338. /(.*)c(.*)/
  2339. abcde
  2340. /\((.*), (.*)\)/
  2341. (a, b)
  2342. /[k]/
  2343. /abcd/
  2344. abcd
  2345. /a(bc)d/
  2346. abcd
  2347. /a[-]?c/
  2348. ac
  2349. /(abc)\1/
  2350. abcabc
  2351. /([a-c]*)\1/
  2352. abcabc
  2353. /(a)|\1/
  2354. a
  2355. ab
  2356. \= Expect no match
  2357. x
  2358. /(([a-c])b*?\2)*/
  2359. ababbbcbc
  2360. /(([a-c])b*?\2){3}/
  2361. ababbbcbc
  2362. /((\3|b)\2(a)x)+/
  2363. aaaxabaxbaaxbbax
  2364. /((\3|b)\2(a)){2,}/
  2365. bbaababbabaaaaabbaaaabba
  2366. /abc/i
  2367. ABC
  2368. XABCY
  2369. ABABC
  2370. \= Expect no match
  2371. aaxabxbaxbbx
  2372. XBC
  2373. AXC
  2374. ABX
  2375. /ab*c/i
  2376. ABC
  2377. /ab*bc/i
  2378. ABC
  2379. ABBC
  2380. /ab*?bc/i
  2381. ABBBBC
  2382. /ab{0,}?bc/i
  2383. ABBBBC
  2384. /ab+?bc/i
  2385. ABBC
  2386. /ab+bc/i
  2387. \= Expect no match
  2388. ABC
  2389. ABQ
  2390. /ab{1,}bc/i
  2391. /ab+bc/i
  2392. ABBBBC
  2393. /ab{1,}?bc/i
  2394. ABBBBC
  2395. /ab{1,3}?bc/i
  2396. ABBBBC
  2397. /ab{3,4}?bc/i
  2398. ABBBBC
  2399. /ab{4,5}?bc/i
  2400. \= Expect no match
  2401. ABQ
  2402. ABBBBC
  2403. /ab??bc/i
  2404. ABBC
  2405. ABC
  2406. /ab{0,1}?bc/i
  2407. ABC
  2408. /ab??bc/i
  2409. /ab??c/i
  2410. ABC
  2411. /ab{0,1}?c/i
  2412. ABC
  2413. /^abc$/i
  2414. ABC
  2415. \= Expect no match
  2416. ABBBBC
  2417. ABCC
  2418. /^abc/i
  2419. ABCC
  2420. /^abc$/i
  2421. /abc$/i
  2422. AABC
  2423. /^/i
  2424. ABC
  2425. /$/i
  2426. ABC
  2427. /a.c/i
  2428. ABC
  2429. AXC
  2430. /a.*?c/i
  2431. AXYZC
  2432. /a.*c/i
  2433. AABC
  2434. \= Expect no match
  2435. AXYZD
  2436. /a[bc]d/i
  2437. ABD
  2438. /a[b-d]e/i
  2439. ACE
  2440. \= Expect no match
  2441. ABC
  2442. ABD
  2443. /a[b-d]/i
  2444. AAC
  2445. /a[-b]/i
  2446. A-
  2447. /a[b-]/i
  2448. A-
  2449. /a]/i
  2450. A]
  2451. /a[]]b/i
  2452. A]B
  2453. /a[^bc]d/i
  2454. AED
  2455. /a[^-b]c/i
  2456. ADC
  2457. \= Expect no match
  2458. ABD
  2459. A-C
  2460. /a[^]b]c/i
  2461. ADC
  2462. /ab|cd/i
  2463. ABC
  2464. ABCD
  2465. /()ef/i
  2466. DEF
  2467. /$b/i
  2468. \= Expect no match
  2469. A]C
  2470. B
  2471. /a\(b/i
  2472. A(B
  2473. /a\(*b/i
  2474. AB
  2475. A((B
  2476. /a\\b/i
  2477. A\\b
  2478. a\\B
  2479. /((a))/i
  2480. ABC
  2481. /(a)b(c)/i
  2482. ABC
  2483. /a+b+c/i
  2484. AABBABC
  2485. /a{1,}b{1,}c/i
  2486. AABBABC
  2487. /a.+?c/i
  2488. ABCABC
  2489. /a.*?c/i
  2490. ABCABC
  2491. /a.{0,5}?c/i
  2492. ABCABC
  2493. /(a+|b)*/i
  2494. AB
  2495. /(a+|b){0,}/i
  2496. AB
  2497. /(a+|b)+/i
  2498. AB
  2499. /(a+|b){1,}/i
  2500. AB
  2501. /(a+|b)?/i
  2502. AB
  2503. /(a+|b){0,1}/i
  2504. AB
  2505. /(a+|b){0,1}?/i
  2506. AB
  2507. /[^ab]*/i
  2508. CDE
  2509. /([abc])*d/i
  2510. ABBBCD
  2511. /([abc])*bcd/i
  2512. ABCD
  2513. /a|b|c|d|e/i
  2514. E
  2515. /(a|b|c|d|e)f/i
  2516. EF
  2517. /abcd*efg/i
  2518. ABCDEFG
  2519. /ab*/i
  2520. XABYABBBZ
  2521. XAYABBBZ
  2522. /(ab|cd)e/i
  2523. ABCDE
  2524. /[abhgefdc]ij/i
  2525. HIJ
  2526. /^(ab|cd)e/i
  2527. \= Expect no match
  2528. ABCDE
  2529. /(abc|)ef/i
  2530. ABCDEF
  2531. /(a|b)c*d/i
  2532. ABCD
  2533. /(ab|ab*)bc/i
  2534. ABC
  2535. /a([bc]*)c*/i
  2536. ABC
  2537. /a([bc]*)(c*d)/i
  2538. ABCD
  2539. /a([bc]+)(c*d)/i
  2540. ABCD
  2541. /a([bc]*)(c+d)/i
  2542. ABCD
  2543. /a[bcd]*dcdcde/i
  2544. ADCDCDE
  2545. /a[bcd]+dcdcde/i
  2546. /(ab|a)b*c/i
  2547. ABC
  2548. /((a)(b)c)(d)/i
  2549. ABCD
  2550. /[a-zA-Z_][a-zA-Z0-9_]*/i
  2551. ALPHA
  2552. /^a(bc+|b[eh])g|.h$/i
  2553. ABH
  2554. /(bc+d$|ef*g.|h?i(j|k))/i
  2555. EFFGZ
  2556. IJ
  2557. REFFGZ
  2558. \= Expect no match
  2559. ADCDCDE
  2560. EFFG
  2561. BCDD
  2562. /((((((((((a))))))))))/i
  2563. A
  2564. /((((((((((a))))))))))\10/i
  2565. AA
  2566. /(((((((((a)))))))))/i
  2567. A
  2568. /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
  2569. A
  2570. /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
  2571. C
  2572. /multiple words of text/i
  2573. \= Expect no match
  2574. AA
  2575. UH-UH
  2576. /multiple words/i
  2577. MULTIPLE WORDS, YEAH
  2578. /(.*)c(.*)/i
  2579. ABCDE
  2580. /\((.*), (.*)\)/i
  2581. (A, B)
  2582. /[k]/i
  2583. /abcd/i
  2584. ABCD
  2585. /a(bc)d/i
  2586. ABCD
  2587. /a[-]?c/i
  2588. AC
  2589. /(abc)\1/i
  2590. ABCABC
  2591. /([a-c]*)\1/i
  2592. ABCABC
  2593. /a(?!b)./
  2594. abad
  2595. /a(?=d)./
  2596. abad
  2597. /a(?=c|d)./
  2598. abad
  2599. /a(?:b|c|d)(.)/
  2600. ace
  2601. /a(?:b|c|d)*(.)/
  2602. ace
  2603. /a(?:b|c|d)+?(.)/
  2604. ace
  2605. acdbcdbe
  2606. /a(?:b|c|d)+(.)/
  2607. acdbcdbe
  2608. /a(?:b|c|d){2}(.)/
  2609. acdbcdbe
  2610. /a(?:b|c|d){4,5}(.)/
  2611. acdbcdbe
  2612. /a(?:b|c|d){4,5}?(.)/
  2613. acdbcdbe
  2614. /((foo)|(bar))*/
  2615. foobar
  2616. /a(?:b|c|d){6,7}(.)/
  2617. acdbcdbe
  2618. /a(?:b|c|d){6,7}?(.)/
  2619. acdbcdbe
  2620. /a(?:b|c|d){5,6}(.)/
  2621. acdbcdbe
  2622. /a(?:b|c|d){5,6}?(.)/
  2623. acdbcdbe
  2624. /a(?:b|c|d){5,7}(.)/
  2625. acdbcdbe
  2626. /a(?:b|c|d){5,7}?(.)/
  2627. acdbcdbe
  2628. /a(?:b|(c|e){1,2}?|d)+?(.)/
  2629. ace
  2630. /^(.+)?B/
  2631. AB
  2632. /^([^a-z])|(\^)$/
  2633. .
  2634. /^[<>]&/
  2635. <&OUT
  2636. /^(a\1?){4}$/
  2637. aaaaaaaaaa
  2638. \= Expect no match
  2639. AB
  2640. aaaaaaaaa
  2641. aaaaaaaaaaa
  2642. /^(a(?(1)\1)){4}$/
  2643. aaaaaaaaaa
  2644. \= Expect no match
  2645. aaaaaaaaa
  2646. aaaaaaaaaaa
  2647. /(?:(f)(o)(o)|(b)(a)(r))*/
  2648. foobar
  2649. /(?<=a)b/
  2650. ab
  2651. \= Expect no match
  2652. cb
  2653. b
  2654. /(?<!c)b/
  2655. ab
  2656. b
  2657. b
  2658. /(?:..)*a/
  2659. aba
  2660. /(?:..)*?a/
  2661. aba
  2662. /^(?:b|a(?=(.)))*\1/
  2663. abc
  2664. /^(){3,5}/
  2665. abc
  2666. /^(a+)*ax/
  2667. aax
  2668. /^((a|b)+)*ax/
  2669. aax
  2670. /^((a|bc)+)*ax/
  2671. aax
  2672. /(a|x)*ab/
  2673. cab
  2674. /(a)*ab/
  2675. cab
  2676. /(?:(?i)a)b/
  2677. ab
  2678. /((?i)a)b/
  2679. ab
  2680. /(?:(?i)a)b/
  2681. Ab
  2682. /((?i)a)b/
  2683. Ab
  2684. /(?:(?i)a)b/
  2685. \= Expect no match
  2686. cb
  2687. aB
  2688. /((?i)a)b/
  2689. /(?i:a)b/
  2690. ab
  2691. /((?i:a))b/
  2692. ab
  2693. /(?i:a)b/
  2694. Ab
  2695. /((?i:a))b/
  2696. Ab
  2697. /(?i:a)b/
  2698. \= Expect no match
  2699. aB
  2700. aB
  2701. /((?i:a))b/
  2702. /(?:(?-i)a)b/i
  2703. ab
  2704. /((?-i)a)b/i
  2705. ab
  2706. /(?:(?-i)a)b/i
  2707. aB
  2708. /((?-i)a)b/i
  2709. aB
  2710. /(?:(?-i)a)b/i
  2711. aB
  2712. \= Expect no match
  2713. Ab
  2714. AB
  2715. /(?-i:a)b/i
  2716. ab
  2717. /((?-i:a))b/i
  2718. ab
  2719. /(?-i:a)b/i
  2720. aB
  2721. /((?-i:a))b/i
  2722. aB
  2723. /(?-i:a)b/i
  2724. \= Expect no match
  2725. AB
  2726. Ab
  2727. /((?-i:a))b/i
  2728. /(?-i:a)b/i
  2729. aB
  2730. /((?-i:a))b/i
  2731. aB
  2732. /(?-i:a)b/i
  2733. \= Expect no match
  2734. Ab
  2735. AB
  2736. /((?-i:a))b/i
  2737. /((?-i:a.))b/i
  2738. \= Expect no match
  2739. AB
  2740. a\nB
  2741. /((?s-i:a.))b/i
  2742. a\nB
  2743. /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
  2744. cabbbb
  2745. /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
  2746. caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  2747. /(ab)\d\1/i
  2748. Ab4ab
  2749. ab4Ab
  2750. /foo\w*\d{4}baz/
  2751. foobar1234baz
  2752. /x(~~)*(?:(?:F)?)?/
  2753. x~~
  2754. /^a(?#xxx){3}c/
  2755. aaac
  2756. /^a (?#xxx) (?#yyy) {3}c/x
  2757. aaac
  2758. /(?<![cd])b/
  2759. \= Expect no match
  2760. B\nB
  2761. dbcb
  2762. /(?<![cd])[ab]/
  2763. dbaacb
  2764. /(?<!(c|d))b/
  2765. /(?<!(c|d))[ab]/
  2766. dbaacb
  2767. /(?<!cd)[ab]/
  2768. cdaccb
  2769. /^(?:a?b?)*$/
  2770. \
  2771. a
  2772. ab
  2773. aaa
  2774. \= Expect no match
  2775. dbcb
  2776. a--
  2777. aa--
  2778. /((?s)^a(.))((?m)^b$)/
  2779. a\nb\nc\n
  2780. /((?m)^b$)/
  2781. a\nb\nc\n
  2782. /(?m)^b/
  2783. a\nb\n
  2784. /(?m)^(b)/
  2785. a\nb\n
  2786. /((?m)^b)/
  2787. a\nb\n
  2788. /\n((?m)^b)/
  2789. a\nb\n
  2790. /((?s).)c(?!.)/
  2791. a\nb\nc\n
  2792. a\nb\nc\n
  2793. /((?s)b.)c(?!.)/
  2794. a\nb\nc\n
  2795. a\nb\nc\n
  2796. /^b/
  2797. /()^b/
  2798. \= Expect no match
  2799. a\nb\nc\n
  2800. a\nb\nc\n
  2801. /((?m)^b)/
  2802. a\nb\nc\n
  2803. /(x)?(?(1)a|b)/
  2804. \= Expect no match
  2805. a
  2806. a
  2807. /(x)?(?(1)b|a)/
  2808. a
  2809. /()?(?(1)b|a)/
  2810. a
  2811. /()(?(1)b|a)/
  2812. /()?(?(1)a|b)/
  2813. a
  2814. /^(\()?blah(?(1)(\)))$/
  2815. (blah)
  2816. blah
  2817. \= Expect no match
  2818. a
  2819. blah)
  2820. (blah
  2821. /^(\(+)?blah(?(1)(\)))$/
  2822. (blah)
  2823. blah
  2824. \= Expect no match
  2825. blah)
  2826. (blah
  2827. /(?(?!a)a|b)/
  2828. /(?(?!a)b|a)/
  2829. a
  2830. /(?(?=a)b|a)/
  2831. \= Expect no match
  2832. a
  2833. a
  2834. /(?(?=a)a|b)/
  2835. a
  2836. /(?=(a+?))(\1ab)/
  2837. aaab
  2838. /^(?=(a+?))\1ab/
  2839. /(\w+:)+/
  2840. one:
  2841. /$(?<=^(a))/
  2842. a
  2843. /(?=(a+?))(\1ab)/
  2844. aaab
  2845. /^(?=(a+?))\1ab/
  2846. \= Expect no match
  2847. aaab
  2848. aaab
  2849. /([\w:]+::)?(\w+)$/
  2850. abcd
  2851. xy:z:::abcd
  2852. /^[^bcd]*(c+)/
  2853. aexycd
  2854. /(a*)b+/
  2855. caab
  2856. /([\w:]+::)?(\w+)$/
  2857. abcd
  2858. xy:z:::abcd
  2859. \= Expect no match
  2860. abcd:
  2861. abcd:
  2862. /^[^bcd]*(c+)/
  2863. aexycd
  2864. /(>a+)ab/
  2865. /(?>a+)b/
  2866. aaab
  2867. /([[:]+)/
  2868. a:[b]:
  2869. /([[=]+)/
  2870. a=[b]=
  2871. /([[.]+)/
  2872. a.[b].
  2873. /((?>a+)b)/
  2874. aaab
  2875. /(?>(a+))b/
  2876. aaab
  2877. /((?>[^()]+)|\([^()]*\))+/
  2878. ((abc(ade)ufh()()x
  2879. /a\Z/
  2880. \= Expect no match
  2881. aaab
  2882. a\nb\n
  2883. /b\Z/
  2884. a\nb\n
  2885. /b\z/
  2886. /b\Z/
  2887. a\nb
  2888. /b\z/
  2889. a\nb
  2890. /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
  2891. a
  2892. abc
  2893. a-b
  2894. 0-9
  2895. a.b
  2896. 5.6.7
  2897. the.quick.brown.fox
  2898. a100.b200.300c
  2899. 12-ab.1245
  2900. \= Expect no match
  2901. \
  2902. .a
  2903. -a
  2904. a-
  2905. a.
  2906. a_b
  2907. a.-
  2908. a..
  2909. ab..bc
  2910. the.quick.brown.fox-
  2911. the.quick.brown.fox.
  2912. the.quick.brown.fox_
  2913. the.quick.brown.fox+
  2914. /(?>.*)(?<=(abcd|wxyz))/
  2915. alphabetabcd
  2916. endingwxyz
  2917. \= Expect no match
  2918. a rather long string that doesn't end with one of them
  2919. /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
  2920. word cat dog elephant mussel cow horse canary baboon snake shark otherword
  2921. \= Expect no match
  2922. word cat dog elephant mussel cow horse canary baboon snake shark
  2923. /word (?>[a-zA-Z0-9]+ ){0,30}otherword/
  2924. \= Expect no match
  2925. word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
  2926. /(?<=\d{3}(?!999))foo/
  2927. 999foo
  2928. 123999foo
  2929. \= Expect no match
  2930. 123abcfoo
  2931. /(?<=(?!...999)\d{3})foo/
  2932. 999foo
  2933. 123999foo
  2934. \= Expect no match
  2935. 123abcfoo
  2936. /(?<=\d{3}(?!999)...)foo/
  2937. 123abcfoo
  2938. 123456foo
  2939. \= Expect no match
  2940. 123999foo
  2941. /(?<=\d{3}...)(?<!999)foo/
  2942. 123abcfoo
  2943. 123456foo
  2944. \= Expect no match
  2945. 123999foo
  2946. /<a[\s]+href[\s]*=[\s]* # find <a href=
  2947. ([\"\'])? # find single or double quote
  2948. (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
  2949. # quote, otherwise match up to next space
  2950. /isx
  2951. <a href=abcd xyz
  2952. <a href=\"abcd xyz pqr\" cats
  2953. <a href=\'abcd xyz pqr\' cats
  2954. /<a\s+href\s*=\s* # find <a href=
  2955. (["'])? # find single or double quote
  2956. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  2957. # quote, otherwise match up to next space
  2958. /isx
  2959. <a href=abcd xyz
  2960. <a href=\"abcd xyz pqr\" cats
  2961. <a href = \'abcd xyz pqr\' cats
  2962. /<a\s+href(?>\s*)=(?>\s*) # find <a href=
  2963. (["'])? # find single or double quote
  2964. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  2965. # quote, otherwise match up to next space
  2966. /isx
  2967. <a href=abcd xyz
  2968. <a href=\"abcd xyz pqr\" cats
  2969. <a href = \'abcd xyz pqr\' cats
  2970. /((Z)+|A)*/
  2971. ZABCDEFG
  2972. /(Z()|A)*/
  2973. ZABCDEFG
  2974. /(Z(())|A)*/
  2975. ZABCDEFG
  2976. /((?>Z)+|A)*/
  2977. ZABCDEFG
  2978. /((?>)+|A)*/
  2979. ZABCDEFG
  2980. /a*/g
  2981. abbab
  2982. /[[:space:]]+/
  2983. > \x09\x0a\x0c\x0d\x0b<
  2984. /[[:blank:]]+/
  2985. > \x09\x0a\x0c\x0d\x0b<
  2986. /[\s]+/
  2987. > \x09\x0a\x0c\x0d\x0b<
  2988. /\s+/
  2989. > \x09\x0a\x0c\x0d\x0b<
  2990. /a b/x
  2991. ab
  2992. /(?!\A)x/m
  2993. a\nxb\n
  2994. /(?!^)x/m
  2995. \= Expect no match
  2996. a\nxb\n
  2997. /abc\Qabc\Eabc/
  2998. abcabcabc
  2999. /abc\Q(*+|\Eabc/
  3000. abc(*+|abc
  3001. / abc\Q abc\Eabc/x
  3002. abc abcabc
  3003. \= Expect no match
  3004. abcabcabc
  3005. /abc#comment
  3006. \Q#not comment
  3007. literal\E/x
  3008. abc#not comment\n literal
  3009. /abc#comment
  3010. \Q#not comment
  3011. literal/x
  3012. abc#not comment\n literal
  3013. /abc#comment
  3014. \Q#not comment
  3015. literal\E #more comment
  3016. /x
  3017. abc#not comment\n literal
  3018. /abc#comment
  3019. \Q#not comment
  3020. literal\E #more comment/x
  3021. abc#not comment\n literal
  3022. /\Qabc\$xyz\E/
  3023. abc\\\$xyz
  3024. /\Qabc\E\$\Qxyz\E/
  3025. abc\$xyz
  3026. /\Gabc/
  3027. abc
  3028. \= Expect no match
  3029. xyzabc
  3030. /\Gabc./g
  3031. abc1abc2xyzabc3
  3032. /abc./g
  3033. abc1abc2xyzabc3
  3034. /a(?x: b c )d/
  3035. XabcdY
  3036. \= Expect no match
  3037. Xa b c d Y
  3038. /((?x)x y z | a b c)/
  3039. XabcY
  3040. AxyzB
  3041. /(?i)AB(?-i)C/
  3042. XabCY
  3043. \= Expect no match
  3044. XabcY
  3045. /((?i)AB(?-i)C|D)E/
  3046. abCE
  3047. DE
  3048. \= Expect no match
  3049. abcE
  3050. abCe
  3051. dE
  3052. De
  3053. /(.*)\d+\1/
  3054. abc123abc
  3055. abc123bc
  3056. /(.*)\d+\1/s
  3057. abc123abc
  3058. abc123bc
  3059. /((.*))\d+\1/
  3060. abc123abc
  3061. abc123bc
  3062. # This tests for an IPv6 address in the form where it can have up to
  3063. # eight components, one and only one of which is empty. This must be
  3064. # an internal component.
  3065. /^(?!:) # colon disallowed at start
  3066. (?: # start of item
  3067. (?: [0-9a-f]{1,4} | # 1-4 hex digits or
  3068. (?(1)0 | () ) ) # if null previously matched, fail; else null
  3069. : # followed by colon
  3070. ){1,7} # end item; 1-7 of them required
  3071. [0-9a-f]{1,4} $ # final hex number at end of string
  3072. (?(1)|.) # check that there was an empty component
  3073. /ix
  3074. a123::a123
  3075. a123:b342::abcd
  3076. a123:b342::324e:abcd
  3077. a123:ddde:b342::324e:abcd
  3078. a123:ddde:b342::324e:dcba:abcd
  3079. a123:ddde:9999:b342::324e:dcba:abcd
  3080. \= Expect no match
  3081. 1:2:3:4:5:6:7:8
  3082. a123:bce:ddde:9999:b342::324e:dcba:abcd
  3083. a123::9999:b342::324e:dcba:abcd
  3084. abcde:2:3:4:5:6:7:8
  3085. ::1
  3086. abcd:fee0:123::
  3087. :1
  3088. 1:
  3089. /[z\Qa-d]\E]/
  3090. z
  3091. a
  3092. -
  3093. d
  3094. ]
  3095. \= Expect no match
  3096. b
  3097. /(a+)*b/
  3098. \= Expect no match
  3099. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3100. /(?i)reg(?:ul(?:[aä]|ae)r|ex)/
  3101. REGular
  3102. regulaer
  3103. Regex
  3104. regulär
  3105. /Åæåä[à-ÿÀ-ß]+/
  3106. Åæåäà
  3107. Åæåäÿ
  3108. ÅæåäÀ
  3109. Åæåäß
  3110. /(?<=Z)X./
  3111. \x84XAZXB
  3112. /ab cd (?x) de fg/
  3113. ab cd defg
  3114. /ab cd(?x) de fg/
  3115. ab cddefg
  3116. \= Expect no match
  3117. abcddefg
  3118. /(?<![^f]oo)(bar)/
  3119. foobarX
  3120. \= Expect no match
  3121. boobarX
  3122. /(?<![^f])X/
  3123. offX
  3124. \= Expect no match
  3125. onyX
  3126. /(?<=[^f])X/
  3127. onyX
  3128. \= Expect no match
  3129. offX
  3130. /^/gm
  3131. a\nb\nc\n
  3132. \
  3133. /(?<=C\n)^/gm
  3134. A\nC\nC\n
  3135. /(?:(?(1)a|b)(X))+/
  3136. bXaX
  3137. /(?:(?(1)\1a|b)(X|Y))+/
  3138. bXXaYYaY
  3139. bXYaXXaX
  3140. /()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
  3141. bXXaYYaY
  3142. /[[,abc,]+]/
  3143. abc]
  3144. a,b]
  3145. [a,b,c]
  3146. /(?-x: )/x
  3147. A\x20B
  3148. /(?x)(?-x: \s*#\s*)/
  3149. A # B
  3150. \= Expect no match
  3151. #
  3152. A s#s B
  3153. /(?x-is)(?:(?-ixs) \s*#\s*) include/
  3154. A #include
  3155. \= Expect no match
  3156. A#include
  3157. A #Include
  3158. /a*b*\w/
  3159. aaabbbb
  3160. aaaa
  3161. a
  3162. /a*b?\w/
  3163. aaabbbb
  3164. aaaa
  3165. a
  3166. /a*b{0,4}\w/
  3167. aaabbbb
  3168. aaaa
  3169. a
  3170. /a*b{0,}\w/
  3171. aaabbbb
  3172. aaaa
  3173. a
  3174. /a*\d*\w/
  3175. 0a
  3176. a
  3177. /a*b *\w/x
  3178. a
  3179. /a*b#comment
  3180. *\w/x
  3181. a
  3182. /a* b *\w/x
  3183. a
  3184. /^\w+=.*(\\\n.*)*/
  3185. abc=xyz\\\npqr
  3186. /(?=(\w+))\1:/
  3187. abcd:
  3188. /^(?=(\w+))\1:/
  3189. abcd:
  3190. /^\Eabc/
  3191. abc
  3192. /^[\Eabc]/
  3193. a
  3194. \= Expect no match
  3195. E
  3196. /^[a-\Ec]/
  3197. b
  3198. \= Expect no match
  3199. -
  3200. E
  3201. /^[a\E\E-\Ec]/
  3202. b
  3203. \= Expect no match
  3204. -
  3205. E
  3206. /^[\E\Qa\E-\Qz\E]+/
  3207. b
  3208. \= Expect no match
  3209. -
  3210. /^[a\Q]bc\E]/
  3211. a
  3212. ]
  3213. c
  3214. /^[a-\Q\E]/
  3215. a
  3216. -
  3217. /^(a()*)*/
  3218. aaaa
  3219. /^(?:a(?:(?:))*)*/
  3220. aaaa
  3221. /^(a()+)+/
  3222. aaaa
  3223. /^(?:a(?:(?:))+)+/
  3224. aaaa
  3225. /(a){0,3}(?(1)b|(c|))*D/
  3226. abbD
  3227. ccccD
  3228. D
  3229. /(a|)*\d/
  3230. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3231. \= Expect no match
  3232. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3233. /(?>a|)*\d/
  3234. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3235. \= Expect no match
  3236. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3237. /(?:a|)*\d/
  3238. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3239. \= Expect no match
  3240. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3241. /\Z/g
  3242. abc\n
  3243. /^(?s)(?>.*)(?<!\n)/
  3244. abc
  3245. \= Expect no match
  3246. abc\n
  3247. /^(?![^\n]*\n\z)/
  3248. abc
  3249. \= Expect no match
  3250. abc\n
  3251. /\z(?<!\n)/
  3252. abc
  3253. \= Expect no match
  3254. abc\n
  3255. /(.*(.)?)*/
  3256. abcd
  3257. /( (A | (?(1)0|) )* )/x
  3258. abcd
  3259. /( ( (?(1)0|) )* )/x
  3260. abcd
  3261. /( (?(1)0|)* )/x
  3262. abcd
  3263. /[[:abcd:xyz]]/
  3264. a]
  3265. :]
  3266. /[abc[:x\]pqr]/
  3267. a
  3268. [
  3269. :
  3270. ]
  3271. p
  3272. /.*[op][xyz]/
  3273. \= Expect no match
  3274. fooabcfoo
  3275. /(?(?=.*b)b|^)/
  3276. adc
  3277. abc
  3278. /(?(?=^.*b)b|^)/
  3279. adc
  3280. \= Expect no match
  3281. abc
  3282. /(?(?=.*b)b|^)*/
  3283. adc
  3284. abc
  3285. /(?(?=.*b)b|^)+/
  3286. adc
  3287. abc
  3288. /(?(?=b).*b|^d)/
  3289. abc
  3290. /(?(?=.*b).*b|^d)/
  3291. abc
  3292. /^%((?(?=[a])[^%])|b)*%$/
  3293. %ab%
  3294. /(?i)a(?-i)b|c/
  3295. XabX
  3296. XAbX
  3297. CcC
  3298. \= Expect no match
  3299. XABX
  3300. /[\x00-\xff\s]+/
  3301. \x0a\x0b\x0c\x0d
  3302. /(abc)\1/i
  3303. \= Expect no match
  3304. abc
  3305. /(abc)\1/
  3306. \= Expect no match
  3307. abc
  3308. /[^a]*/i
  3309. 12abc
  3310. 12ABC
  3311. /[^a]*+/i
  3312. 12abc
  3313. 12ABC
  3314. /[^a]*?X/i
  3315. \= Expect no match
  3316. 12abc
  3317. 12ABC
  3318. /[^a]+?X/i
  3319. \= Expect no match
  3320. 12abc
  3321. 12ABC
  3322. /[^a]?X/i
  3323. 12aXbcX
  3324. 12AXBCX
  3325. BCX
  3326. /[^a]??X/i
  3327. 12aXbcX
  3328. 12AXBCX
  3329. BCX
  3330. /[^a]?+X/i
  3331. 12aXbcX
  3332. 12AXBCX
  3333. BCX
  3334. /[^a]{2,3}/i
  3335. abcdef
  3336. ABCDEF
  3337. /[^a]{2,3}?/i
  3338. abcdef
  3339. ABCDEF
  3340. /[^a]{2,3}+/i
  3341. abcdef
  3342. ABCDEF
  3343. /((a|)+)+Z/
  3344. Z
  3345. /(a)b|(a)c/
  3346. ac
  3347. /(?>(a))b|(a)c/
  3348. ac
  3349. /(?=(a))ab|(a)c/
  3350. ac
  3351. /((?>(a))b|(a)c)/
  3352. ac
  3353. /((?>(a))b|(a)c)++/
  3354. ac
  3355. /(?:(?>(a))b|(a)c)++/
  3356. ac
  3357. /(?=(?>(a))b|(a)c)(..)/
  3358. ac
  3359. /(?>(?>(a))b|(a)c)/
  3360. ac
  3361. /(?:(?>([ab])))+a=/aftertext
  3362. =ba=
  3363. /(?>([ab]))+a=/aftertext
  3364. =ba=
  3365. /((?>(a+)b)+(aabab))/
  3366. aaaabaaabaabab
  3367. /(?>a+|ab)+?c/
  3368. \= Expect no match
  3369. aabc
  3370. /(?>a+|ab)+c/
  3371. \= Expect no match
  3372. aabc
  3373. /(?:a+|ab)+c/
  3374. aabc
  3375. /(?(?=(a))a)/
  3376. a
  3377. /(?(?=(a))a)(b)/
  3378. ab
  3379. /^(?:a|ab)++c/
  3380. \= Expect no match
  3381. aaaabc
  3382. /^(?>a|ab)++c/
  3383. \= Expect no match
  3384. aaaabc
  3385. /^(?:a|ab)+c/
  3386. aaaabc
  3387. /(?=abc){3}abc/aftertext
  3388. abcabcabc
  3389. \= Expect no match
  3390. xyz
  3391. /(?=abc)+abc/aftertext
  3392. abcabcabc
  3393. \= Expect no match
  3394. xyz
  3395. /(?=abc)++abc/aftertext
  3396. abcabcabc
  3397. \= Expect no match
  3398. xyz
  3399. /(?=abc){0}xyz/
  3400. xyz
  3401. /(?=abc){1}xyz/
  3402. \= Expect no match
  3403. xyz
  3404. /(?=(a))?./
  3405. ab
  3406. bc
  3407. /(?=(a))??./
  3408. ab
  3409. bc
  3410. /^(?=(?1))?[az]([abc])d/
  3411. abd
  3412. zcdxx
  3413. /^(?!a){0}\w+/
  3414. aaaaa
  3415. /(?<=(abc))?xyz/
  3416. abcxyz
  3417. pqrxyz
  3418. /^[\g<a>]+/
  3419. ggg<<<aaa>>>
  3420. \= Expect no match
  3421. \\ga
  3422. /^[\ga]+/
  3423. gggagagaxyz
  3424. /^[:a[:digit:]]+/
  3425. aaaa444:::Z
  3426. /^[:a[:digit:]:b]+/
  3427. aaaa444:::bbbZ
  3428. /[:a]xxx[b:]/
  3429. :xxx:
  3430. /(?<=a{2})b/i
  3431. xaabc
  3432. \= Expect no match
  3433. xabc
  3434. /(?<!a{2})b/i
  3435. xabc
  3436. \= Expect no match
  3437. xaabc
  3438. /(?<=a\h)c/
  3439. xa c
  3440. /(?<=[^a]{2})b/
  3441. axxbc
  3442. aAAbc
  3443. \= Expect no match
  3444. xaabc
  3445. /(?<=[^a]{2})b/i
  3446. axxbc
  3447. \= Expect no match
  3448. aAAbc
  3449. xaabc
  3450. /(?<=a\H)c/
  3451. abc
  3452. /(?<=a\V)c/
  3453. abc
  3454. /(?<=a\v)c/
  3455. a\nc
  3456. /(?(?=c)c|d)++Y/
  3457. XcccddYX
  3458. /(?(?=c)c|d)*+Y/
  3459. XcccddYX
  3460. /^(a{2,3}){2,}+a/
  3461. aaaaaaa
  3462. \= Expect no match
  3463. aaaaaa
  3464. aaaaaaaaa
  3465. /^(a{2,3})++a/
  3466. \= Expect no match
  3467. aaaaaa
  3468. /^(a{2,3})*+a/
  3469. \= Expect no match
  3470. aaaaaa
  3471. /\H\h\V\v/
  3472. X X\x0a
  3473. X\x09X\x0b
  3474. \= Expect no match
  3475. \xa0 X\x0a
  3476. /\H*\h+\V?\v{3,4}/
  3477. \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
  3478. \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
  3479. \x09\x20\xa0\x0a\x0b\x0c
  3480. \= Expect no match
  3481. \x09\x20\xa0\x0a\x0b
  3482. /\H{3,4}/
  3483. XY ABCDE
  3484. XY PQR ST
  3485. /.\h{3,4}./
  3486. XY AB PQRS
  3487. /\h*X\h?\H+Y\H?Z/
  3488. >XNNNYZ
  3489. > X NYQZ
  3490. \= Expect no match
  3491. >XYZ
  3492. > X NY Z
  3493. /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
  3494. >XY\x0aZ\x0aA\x0bNN\x0c
  3495. >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
  3496. /(foo)\Kbar/
  3497. foobar
  3498. /(foo)(\Kbar|baz)/
  3499. foobar
  3500. foobaz
  3501. /(foo\Kbar)baz/
  3502. foobarbaz
  3503. /abc\K|def\K/g,aftertext
  3504. Xabcdefghi
  3505. /ab\Kc|de\Kf/g,aftertext
  3506. Xabcdefghi
  3507. /(?=C)/g,aftertext
  3508. ABCDECBA
  3509. /^abc\K/aftertext
  3510. abcdef
  3511. \= Expect no match
  3512. defabcxyz
  3513. /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/
  3514. ababababbbabZXXXX
  3515. /(?<A>tom|bon)-\g{A}/
  3516. tom-tom
  3517. bon-bon
  3518. /(^(a|b\g{-1}))/
  3519. \= Expect no match
  3520. bacxxx
  3521. /(?|(abc)|(xyz))\1/
  3522. abcabc
  3523. xyzxyz
  3524. \= Expect no match
  3525. abcxyz
  3526. xyzabc
  3527. /(?|(abc)|(xyz))(?1)/
  3528. abcabc
  3529. xyzabc
  3530. \= Expect no match
  3531. xyzxyz
  3532. /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
  3533. XYabcdY
  3534. /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
  3535. XYabcdY
  3536. /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
  3537. XYabcdY
  3538. /(?'abc'\w+):\k<abc>{2}/
  3539. a:aaxyz
  3540. ab:ababxyz
  3541. \= Expect no match
  3542. a:axyz
  3543. ab:abxyz
  3544. /(?'abc'\w+):\g{abc}{2}/
  3545. a:aaxyz
  3546. ab:ababxyz
  3547. \= Expect no match
  3548. a:axyz
  3549. ab:abxyz
  3550. /^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
  3551. abd
  3552. ce
  3553. /^(a.)\g-1Z/
  3554. aXaXZ
  3555. /^(a.)\g{-1}Z/
  3556. aXaXZ
  3557. /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
  3558. abcd
  3559. /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
  3560. (?(DEFINE)
  3561. (?<NAME_PAT>[a-z]+)
  3562. (?<ADDRESS_PAT>\d+)
  3563. )/x
  3564. metcalfe 33
  3565. /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  3566. 1.2.3.4
  3567. 131.111.10.206
  3568. 10.0.0.0
  3569. \= Expect no match
  3570. 10.6
  3571. 455.3.4.5
  3572. /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  3573. 1.2.3.4
  3574. 131.111.10.206
  3575. 10.0.0.0
  3576. \= Expect no match
  3577. 10.6
  3578. 455.3.4.5
  3579. /^(\w++|\s++)*$/
  3580. now is the time for all good men to come to the aid of the party
  3581. \= Expect no match
  3582. this is not a line with only words and spaces!
  3583. /(\d++)(\w)/
  3584. 12345a
  3585. \= Expect no match
  3586. 12345+
  3587. /a++b/
  3588. aaab
  3589. /(a++b)/
  3590. aaab
  3591. /(a++)b/
  3592. aaab
  3593. /([^()]++|\([^()]*\))+/
  3594. ((abc(ade)ufh()()x
  3595. /\(([^()]++|\([^()]+\))+\)/
  3596. (abc)
  3597. (abc(def)xyz)
  3598. \= Expect no match
  3599. ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3600. /^([^()]|\((?1)*\))*$/
  3601. abc
  3602. a(b)c
  3603. a(b(c))d
  3604. \= Expect no match)
  3605. a(b(c)d
  3606. /^>abc>([^()]|\((?1)*\))*<xyz<$/
  3607. >abc>123<xyz<
  3608. >abc>1(2)3<xyz<
  3609. >abc>(1(2)3)<xyz<
  3610. /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
  3611. 1221
  3612. Satanoscillatemymetallicsonatas
  3613. AmanaplanacanalPanama
  3614. AblewasIereIsawElba
  3615. \= Expect no match
  3616. Thequickbrownfox
  3617. /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
  3618. 12
  3619. (((2+2)*-3)-7)
  3620. -12
  3621. \= Expect no match
  3622. ((2+2)*-3)-7)
  3623. /^(x(y|(?1){2})z)/
  3624. xyz
  3625. xxyzxyzz
  3626. \= Expect no match
  3627. xxyzz
  3628. xxyzxyzxyzz
  3629. /((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
  3630. <>
  3631. <abcd>
  3632. <abc <123> hij>
  3633. <abc <def> hij>
  3634. <abc<>def>
  3635. <abc<>
  3636. \= Expect no match
  3637. <abc
  3638. /^a+(*FAIL)/
  3639. \= Expect no match
  3640. aaaaaa
  3641. /a+b?c+(*FAIL)/
  3642. \= Expect no match
  3643. aaabccc
  3644. /a+b?(*PRUNE)c+(*FAIL)/
  3645. \= Expect no match
  3646. aaabccc
  3647. /a+b?(*COMMIT)c+(*FAIL)/
  3648. \= Expect no match
  3649. aaabccc
  3650. /a+b?(*SKIP)c+(*FAIL)/
  3651. \= Expect no match
  3652. aaabcccaaabccc
  3653. /^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  3654. aaaxxxxxx
  3655. aaa++++++
  3656. bbbxxxxx
  3657. bbb+++++
  3658. cccxxxx
  3659. ccc++++
  3660. dddddddd
  3661. /^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  3662. aaaxxxxxx
  3663. aaa++++++
  3664. bbbxxxxx
  3665. bbb+++++
  3666. cccxxxx
  3667. ccc++++
  3668. dddddddd
  3669. /a+b?(*THEN)c+(*FAIL)/
  3670. \= Expect no match
  3671. aaabccc
  3672. /(A (A|B(*ACCEPT)|C) D)(E)/x
  3673. AB
  3674. ABX
  3675. AADE
  3676. ACDE
  3677. \= Expect no match
  3678. AD
  3679. /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  3680. 1221
  3681. Satan, oscillate my metallic sonatas!
  3682. A man, a plan, a canal: Panama!
  3683. Able was I ere I saw Elba.
  3684. \= Expect no match
  3685. The quick brown fox
  3686. /^((.)(?1)\2|.)$/
  3687. a
  3688. aba
  3689. aabaa
  3690. abcdcba
  3691. pqaabaaqp
  3692. ablewasiereisawelba
  3693. \= Expect no match
  3694. rhubarb
  3695. the quick brown fox
  3696. /(a)(?<=b(?1))/
  3697. baz
  3698. \= Expect no match
  3699. caz
  3700. /(?<=b(?1))(a)/
  3701. zbaaz
  3702. \= Expect no match
  3703. aaa
  3704. /(?<X>a)(?<=b(?&X))/
  3705. baz
  3706. /^(?|(abc)|(def))\1/
  3707. abcabc
  3708. defdef
  3709. \= Expect no match
  3710. abcdef
  3711. defabc
  3712. /^(?|(abc)|(def))(?1)/
  3713. abcabc
  3714. defabc
  3715. \= Expect no match
  3716. defdef
  3717. abcdef
  3718. /(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames
  3719. a\"aaaaa
  3720. b\"aaaaa
  3721. \= Expect no match
  3722. b\"11111
  3723. /(?:(?1)|B)(A(*F)|C)/
  3724. ABCD
  3725. CCD
  3726. \= Expect no match
  3727. CAD
  3728. /^(?:(?1)|B)(A(*F)|C)/
  3729. CCD
  3730. BCD
  3731. \= Expect no match
  3732. ABCD
  3733. CAD
  3734. BAD
  3735. /(?:(?1)|B)(A(*ACCEPT)XX|C)D/
  3736. AAD
  3737. ACD
  3738. BAD
  3739. BCD
  3740. BAX
  3741. \= Expect no match
  3742. ACX
  3743. ABC
  3744. /(?(DEFINE)(A))B(?1)C/
  3745. BAC
  3746. /(?(DEFINE)((A)\2))B(?1)C/
  3747. BAAC
  3748. /(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
  3749. (ab(cd)ef)
  3750. /^(?=a(*SKIP)b|ac)/
  3751. \= Expect no match
  3752. ac
  3753. /^(?=a(*PRUNE)b)/
  3754. ab
  3755. \= Expect no match
  3756. ac
  3757. /^(?=a(*ACCEPT)b)/
  3758. ac
  3759. /(?>a\Kb)/
  3760. ab
  3761. /((?>a\Kb))/
  3762. ab
  3763. /(a\Kb)/
  3764. ab
  3765. /^a\Kcz|ac/
  3766. ac
  3767. /(?>a\Kbz|ab)/
  3768. ab
  3769. /^(?&t)(?(DEFINE)(?<t>a\Kb))$/
  3770. ab
  3771. /^([^()]|\((?1)*\))*$/
  3772. a(b)c
  3773. a(b(c)d)e
  3774. /(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
  3775. 0
  3776. 00
  3777. 0000
  3778. /(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
  3779. 0
  3780. 00
  3781. 0000
  3782. # This one does fail, as expected, in Perl. It needs the complex item at the
  3783. # end of the pattern. A single letter instead of (B|D) makes it not fail, which
  3784. # I think is a Perl bug.
  3785. /A(*COMMIT)(B|D)/
  3786. \= Expect no match
  3787. ACABX
  3788. # Check the use of names for failure
  3789. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  3790. \= Expect no match
  3791. AC
  3792. CB
  3793. /(*MARK:A)(*SKIP:B)(C|X)/mark
  3794. C
  3795. \= Expect no match
  3796. D
  3797. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  3798. \= Expect no match
  3799. CB
  3800. /^(?:A(*THEN:A)B|C(*THEN:B)D)/mark
  3801. \= Expect no match
  3802. CB
  3803. /^(?>A(*THEN:A)B|C(*THEN:B)D)/mark
  3804. \= Expect no match
  3805. CB
  3806. # This should succeed, as the skip causes bump to offset 1 (the mark). Note
  3807. # that we have to have something complicated such as (B|Z) at the end because,
  3808. # for Perl, a simple character somehow causes an unwanted optimization to mess
  3809. # with the handling of backtracking verbs.
  3810. /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  3811. AAAC
  3812. # Test skipping over a non-matching mark.
  3813. /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/x,mark
  3814. AAAC
  3815. # Check shorthand for MARK.
  3816. /A(*:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  3817. AAAC
  3818. /(*:A)A+(*SKIP:A)(B|Z)/mark
  3819. \= Expect no match
  3820. AAAC
  3821. # This should succeed, as a non-existent skip name disables the skip.
  3822. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  3823. AAAC
  3824. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/x,mark
  3825. AAAC
  3826. # COMMIT at the start of a pattern should act like an anchor. Again, however,
  3827. # we need the complication for Perl.
  3828. /(*COMMIT)(A|P)(B|P)(C|P)/
  3829. ABCDEFG
  3830. \= Expect no match
  3831. DEFGABC
  3832. # COMMIT inside an atomic group can't stop backtracking over the group.
  3833. /(\w+)(?>b(*COMMIT))\w{2}/
  3834. abbb
  3835. /(\w+)b(*COMMIT)\w{2}/
  3836. \= Expect no match
  3837. abbb
  3838. # Check opening parens in comment when seeking forward reference.
  3839. /(?&t)(?#()(?(DEFINE)(?<t>a))/
  3840. bac
  3841. # COMMIT should override THEN.
  3842. /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
  3843. \= Expect no match
  3844. yes
  3845. /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
  3846. \= Expect no match
  3847. yes
  3848. /b?(*SKIP)c/
  3849. bc
  3850. abc
  3851. /(*SKIP)bc/
  3852. \= Expect no match
  3853. a
  3854. /(*SKIP)b/
  3855. \= Expect no match
  3856. a
  3857. /(?P<abn>(?P=abn)xxx|)+/
  3858. xxx
  3859. /(?i:([^b]))(?1)/
  3860. aa
  3861. aA
  3862. \= Expect no match
  3863. ab
  3864. aB
  3865. Ba
  3866. ba
  3867. /^(?&t)*+(?(DEFINE)(?<t>a))\w$/
  3868. aaaaaaX
  3869. \= Expect no match
  3870. aaaaaa
  3871. /^(?&t)*(?(DEFINE)(?<t>a))\w$/
  3872. aaaaaaX
  3873. aaaaaa
  3874. /^(a)*+(\w)/
  3875. aaaaX
  3876. YZ
  3877. \= Expect no match
  3878. aaaa
  3879. /^(?:a)*+(\w)/
  3880. aaaaX
  3881. YZ
  3882. \= Expect no match
  3883. aaaa
  3884. /^(a)++(\w)/
  3885. aaaaX
  3886. \= Expect no match
  3887. aaaa
  3888. YZ
  3889. /^(?:a)++(\w)/
  3890. aaaaX
  3891. \= Expect no match
  3892. aaaa
  3893. YZ
  3894. /^(a)?+(\w)/
  3895. aaaaX
  3896. YZ
  3897. /^(?:a)?+(\w)/
  3898. aaaaX
  3899. YZ
  3900. /^(a){2,}+(\w)/
  3901. aaaaX
  3902. \= Expect no match
  3903. aaa
  3904. YZ
  3905. /^(?:a){2,}+(\w)/
  3906. aaaaX
  3907. \= Expect no match
  3908. aaa
  3909. YZ
  3910. /(a|)*(?1)b/
  3911. b
  3912. ab
  3913. aab
  3914. /(a)++(?1)b/
  3915. \= Expect no match
  3916. ab
  3917. aab
  3918. /(a)*+(?1)b/
  3919. \= Expect no match
  3920. ab
  3921. aab
  3922. /(?1)(?:(b)){0}/
  3923. b
  3924. /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
  3925. foo(bar(baz)+baz(bop))
  3926. /(A (A|B(*ACCEPT)|C) D)(E)/x
  3927. AB
  3928. /\A.*?(a|bc)/
  3929. ba
  3930. /\A.*?(?:a|bc)++/
  3931. ba
  3932. /\A.*?(a|bc)++/
  3933. ba
  3934. /\A.*?(?:a|bc|d)/
  3935. ba
  3936. /(?:(b))++/
  3937. beetle
  3938. /(?(?=(a(*ACCEPT)z))a)/
  3939. a
  3940. /^(a)(?1)+ab/
  3941. aaaab
  3942. /^(a)(?1)++ab/
  3943. \= Expect no match
  3944. aaaab
  3945. /^(?=a(*:M))aZ/mark
  3946. aZbc
  3947. /^(?!(*:M)b)aZ/mark
  3948. aZbc
  3949. /(?(DEFINE)(a))?b(?1)/
  3950. backgammon
  3951. /^\N+/
  3952. abc\ndef
  3953. /^\N{1,}/
  3954. abc\ndef
  3955. /(?(R)a+|(?R)b)/
  3956. aaaabcde
  3957. /(?(R)a+|((?R))b)/
  3958. aaaabcde
  3959. /((?(R)a+|(?1)b))/
  3960. aaaabcde
  3961. /((?(R1)a+|(?1)b))/
  3962. aaaabcde
  3963. /((?(R)a|(?1)))*/
  3964. aaa
  3965. /((?(R)a|(?1)))+/
  3966. aaa
  3967. /a(*:any
  3968. name)/mark
  3969. abc
  3970. /(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
  3971. a
  3972. ba
  3973. bba
  3974. # Checking revised (*THEN) handling.
  3975. # Capture
  3976. /^.*? (a(*THEN)b) c/x
  3977. \= Expect no match
  3978. aabc
  3979. /^.*? (a(*THEN)b|(*F)) c/x
  3980. aabc
  3981. /^.*? ( (a(*THEN)b) | (*F) ) c/x
  3982. aabc
  3983. /^.*? ( (a(*THEN)b) ) c/x
  3984. \= Expect no match
  3985. aabc
  3986. # Non-capture
  3987. /^.*? (?:a(*THEN)b) c/x
  3988. \= Expect no match
  3989. aabc
  3990. /^.*? (?:a(*THEN)b|(*F)) c/x
  3991. aabc
  3992. /^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
  3993. aabc
  3994. /^.*? (?: (?:a(*THEN)b) ) c/x
  3995. \= Expect no match
  3996. aabc
  3997. # Atomic
  3998. /^.*? (?>a(*THEN)b) c/x
  3999. \= Expect no match
  4000. aabc
  4001. /^.*? (?>a(*THEN)b|(*F)) c/x
  4002. aabc
  4003. /^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
  4004. aabc
  4005. /^.*? (?> (?>a(*THEN)b) ) c/x
  4006. \= Expect no match
  4007. aabc
  4008. # Possessive capture
  4009. /^.*? (a(*THEN)b)++ c/x
  4010. \= Expect no match
  4011. aabc
  4012. /^.*? (a(*THEN)b|(*F))++ c/x
  4013. aabc
  4014. /^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
  4015. aabc
  4016. /^.*? ( (a(*THEN)b)++ )++ c/x
  4017. \= Expect no match
  4018. aabc
  4019. # Possessive non-capture
  4020. /^.*? (?:a(*THEN)b)++ c/x
  4021. \= Expect no match
  4022. aabc
  4023. /^.*? (?:a(*THEN)b|(*F))++ c/x
  4024. aabc
  4025. /^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
  4026. aabc
  4027. /^.*? (?: (?:a(*THEN)b)++ )++ c/x
  4028. \= Expect no match
  4029. aabc
  4030. # Condition assertion
  4031. /^(?(?=a(*THEN)b)ab|ac)/
  4032. ac
  4033. # Condition
  4034. /^.*?(?(?=a)a|b(*THEN)c)/
  4035. \= Expect no match
  4036. ba
  4037. /^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
  4038. ba
  4039. /^.*?(?(?=a)a(*THEN)b|c)/
  4040. \= Expect no match
  4041. ac
  4042. # Assertion
  4043. /^.*(?=a(*THEN)b)/
  4044. aabc
  4045. # --------------------------
  4046. /(?>a(*:m))/imsx,mark
  4047. a
  4048. /(?>(a)(*:m))/imsx,mark
  4049. a
  4050. /(?<=a(*ACCEPT)b)c/
  4051. xacd
  4052. /(?<=(a(*ACCEPT)b))c/
  4053. xacd
  4054. /(?<=(a(*COMMIT)b))c/
  4055. xabcd
  4056. \= Expect no match
  4057. xacd
  4058. /(?<!a(*FAIL)b)c/
  4059. xcd
  4060. acd
  4061. /(?<=a(*:N)b)c/mark
  4062. xabcd
  4063. /(?<=a(*PRUNE)b)c/
  4064. xabcd
  4065. /(?<=a(*SKIP)b)c/
  4066. xabcd
  4067. /(?<=a(*THEN)b)c/
  4068. xabcd
  4069. /(a)(?2){2}(.)/
  4070. abcd
  4071. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  4072. C
  4073. \= Expect no match
  4074. D
  4075. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  4076. C
  4077. \= Expect no match
  4078. D
  4079. /(*MARK:A)(*THEN:B)(C|X)/mark
  4080. C
  4081. \= Expect no match
  4082. D
  4083. /(*MARK:A)(*THEN:B)(C|X)/mark,no_start_optimize
  4084. C
  4085. \= Expect no match
  4086. D
  4087. /(*MARK:A)(*THEN:B)(C|X)/mark
  4088. C
  4089. \= Expect no match
  4090. D
  4091. # This should fail, as the skip causes a bump to offset 3 (the skip).
  4092. /A(*MARK:A)A+(*SKIP)(B|Z) | AC/x,mark
  4093. \= Expect no match
  4094. AAAC
  4095. # Same
  4096. /A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/x,mark
  4097. \= Expect no match
  4098. AAAC
  4099. /A(*:A)A+(*SKIP)(B|Z) | AC/x,mark
  4100. \= Expect no match
  4101. AAAC
  4102. # This should fail, as a null name is the same as no name.
  4103. /A(*MARK:A)A+(*SKIP:)(B|Z) | AC/x,mark
  4104. \= Expect no match
  4105. AAAC
  4106. # A check on what happens after hitting a mark and them bumping along to
  4107. # something that does not even start. Perl reports tags after the failures
  4108. # here, though it does not when the individual letters are made into something
  4109. # more complicated.
  4110. /A(*:A)B|XX(*:B)Y/mark
  4111. AABC
  4112. XXYZ
  4113. \= Expect no match
  4114. XAQQ
  4115. XAQQXZZ
  4116. AXQQQ
  4117. AXXQQQ
  4118. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  4119. AB
  4120. CD
  4121. \= Expect no match
  4122. AC
  4123. CB
  4124. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  4125. AB
  4126. CD
  4127. \= Expect no match
  4128. AC
  4129. CB
  4130. # An empty name does not pass back an empty string. It is the same as if no
  4131. # name were given.
  4132. /^(A(*PRUNE:)B|C(*PRUNE:B)D)/mark
  4133. AB
  4134. CD
  4135. # PRUNE goes to next bumpalong; COMMIT does not.
  4136. /A(*PRUNE:A)B/mark
  4137. ACAB
  4138. # Mark names can be duplicated.
  4139. /A(*:A)B|X(*:A)Y/mark
  4140. AABC
  4141. XXYZ
  4142. /b(*:m)f|a(*:n)w/mark
  4143. aw
  4144. \= Expect no match
  4145. abc
  4146. /b(*:m)f|aw/mark
  4147. abaw
  4148. \= Expect no match
  4149. abc
  4150. abax
  4151. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/x,mark
  4152. AAAC
  4153. /(?=a(*MARK:A)b)..x/mark
  4154. abxy
  4155. \= Expect no match
  4156. abpq
  4157. /(?=a(*MARK:A)b)..(*:Y)x/mark
  4158. abxy
  4159. \= Expect no match
  4160. abpq
  4161. /(?=a(*PRUNE:A)b)..x/mark
  4162. abxy
  4163. \= Expect no match
  4164. abpq
  4165. /(?=a(*PRUNE:A)b)..(*:Y)x/mark
  4166. abxy
  4167. \= Expect no match
  4168. abpq
  4169. /(?=a(*THEN:A)b)..x/mark
  4170. abxy
  4171. \= Expect no match
  4172. abpq
  4173. /(?=a(*THEN:A)b)..(*:Y)x/mark
  4174. abxy
  4175. \= Expect no match
  4176. abpq
  4177. /(another)?(\1?)test/
  4178. hello world test
  4179. /(another)?(\1+)test/
  4180. \= Expect no match
  4181. hello world test
  4182. /(a(*COMMIT)b){0}a(?1)|aac/
  4183. aac
  4184. /((?:a?)*)*c/
  4185. aac
  4186. /((?>a?)*)*c/
  4187. aac
  4188. /(?>.*?a)(?<=ba)/
  4189. aba
  4190. /(?:.*?a)(?<=ba)/
  4191. aba
  4192. /(?>.*?a)b/s
  4193. aab
  4194. /(?>.*?a)b/
  4195. aab
  4196. /(?>^a)b/s
  4197. \= Expect no match
  4198. aab
  4199. /(?>.*?)(?<=(abcd)|(wxyz))/
  4200. alphabetabcd
  4201. endingwxyz
  4202. /(?>.*)(?<=(abcd)|(wxyz))/
  4203. alphabetabcd
  4204. endingwxyz
  4205. /(?>.*)foo/
  4206. \= Expect no match
  4207. abcdfooxyz
  4208. /(?>.*?)foo/
  4209. abcdfooxyz
  4210. /(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/
  4211. ac
  4212. /(?:(a(*SKIP)b)){0}(?:(?1)|ac)/
  4213. ac
  4214. /(?<=(*SKIP)ac)a/
  4215. \= Expect no match
  4216. aa
  4217. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  4218. AAAC
  4219. /a(*SKIP:m)x|ac(*:n)(*SKIP:n)d|ac/mark
  4220. acacd
  4221. /A(*SKIP:m)x|A(*SKIP:n)x|AB/mark
  4222. AB
  4223. /((*SKIP:r)d){0}a(*SKIP:m)x|ac(*:n)|ac/mark
  4224. acacd
  4225. # Tests that try to figure out how Perl works. My hypothesis is that the first
  4226. # verb that is backtracked onto is the one that acts. This seems to be the case
  4227. # almost all the time, but there is one exception that is perhaps a bug.
  4228. # This matches "aaaac"; each PRUNE advances one character until the subject no
  4229. # longer starts with 5 'a's.
  4230. /aaaaa(*PRUNE)b|a+c/
  4231. aaaaaac
  4232. # Putting SKIP in front of PRUNE makes no difference, as it is never
  4233. # backtracked onto, whether or not it has a label.
  4234. /aaaaa(*SKIP)(*PRUNE)b|a+c/
  4235. aaaaaac
  4236. /aaaaa(*SKIP:N)(*PRUNE)b|a+c/
  4237. aaaaaac
  4238. /aaaa(*:N)a(*SKIP:N)(*PRUNE)b|a+c/
  4239. aaaaaac
  4240. # Putting THEN in front makes no difference.
  4241. /aaaaa(*THEN)(*PRUNE)b|a+c/
  4242. aaaaaac
  4243. # However, putting COMMIT in front of the prune changes it to "no match". I
  4244. # think this is inconsistent and possibly a bug. For the moment, running this
  4245. # test is moved out of the Perl-compatible file.
  4246. /aaaaa(*COMMIT)(*PRUNE)b|a+c/
  4247. # OK, lets play the same game again using SKIP instead of PRUNE.
  4248. # This matches "ac" because SKIP forces the next match to start on the
  4249. # sixth "a".
  4250. /aaaaa(*SKIP)b|a+c/
  4251. aaaaaac
  4252. # Putting PRUNE in front makes no difference.
  4253. /aaaaa(*PRUNE)(*SKIP)b|a+c/
  4254. aaaaaac
  4255. # Putting THEN in front makes no difference.
  4256. /aaaaa(*THEN)(*SKIP)b|a+c/
  4257. aaaaaac
  4258. # In this case, neither does COMMIT. This still matches "ac".
  4259. /aaaaa(*COMMIT)(*SKIP)b|a+c/
  4260. aaaaaac
  4261. # This gives "no match", as expected.
  4262. /aaaaa(*COMMIT)b|a+c/
  4263. \= Expect no match
  4264. aaaaaac
  4265. # ---- Tests using THEN ----
  4266. # This matches "aaaaaac", as expected.
  4267. /aaaaa(*THEN)b|a+c/
  4268. aaaaaac
  4269. # Putting SKIP in front makes no difference.
  4270. /aaaaa(*SKIP)(*THEN)b|a+c/
  4271. aaaaaac
  4272. # Putting PRUNE in front makes no difference.
  4273. /aaaaa(*PRUNE)(*THEN)b|a+c/
  4274. aaaaaac
  4275. # Putting COMMIT in front makes no difference.
  4276. /aaaaa(*COMMIT)(*THEN)b|a+c/
  4277. aaaaaac
  4278. # End of "priority" tests
  4279. /aaaaa(*:m)(*PRUNE:m)(*SKIP:m)m|a+/
  4280. aaaaaa
  4281. /aaaaa(*:m)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  4282. aaaaaa
  4283. /aaaaa(*:n)(*PRUNE:m)(*SKIP:m)m|a+/
  4284. aaaaaa
  4285. /aaaaa(*:n)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  4286. aaaaaa
  4287. /a(*MARK:A)aa(*PRUNE:A)a(*SKIP:A)b|a+c/
  4288. aaaac
  4289. /a(*MARK:A)aa(*MARK:A)a(*SKIP:A)b|a+c/
  4290. aaaac
  4291. /aaa(*PRUNE:A)a(*SKIP:A)b|a+c/
  4292. aaaac
  4293. /aaa(*MARK:A)a(*SKIP:A)b|a+c/
  4294. aaaac
  4295. /a(*:m)a(*COMMIT)(*SKIP:m)b|a+c/mark
  4296. aaaaaac
  4297. /.?(a|b(*THEN)c)/
  4298. ba
  4299. /(a(*COMMIT)b)c|abd/
  4300. abc
  4301. \= Expect no match
  4302. abd
  4303. /(?=a(*COMMIT)b)abc|abd/
  4304. abc
  4305. abd
  4306. /(?>a(*COMMIT)b)c|abd/
  4307. abc
  4308. abd
  4309. /a(?=b(*COMMIT)c)[^d]|abd/
  4310. abc
  4311. \= Expect no match
  4312. abd
  4313. /a(?=bc).|abd/
  4314. abd
  4315. abc
  4316. /a(?>b(*COMMIT)c)d|abd/
  4317. \= Expect no match
  4318. abceabd
  4319. /a(?>bc)d|abd/
  4320. abceabd
  4321. /(?>a(*COMMIT)b)c|abd/
  4322. abd
  4323. /(?>a(*COMMIT)c)d|abd/
  4324. \= Expect no match
  4325. abd
  4326. /((?=a(*COMMIT)b)ab|ac){0}(?:(?1)|a(c))/
  4327. ac
  4328. # These tests were formerly in test 2, but changes in PCRE and Perl have
  4329. # made them compatible.
  4330. /^(a)?(?(1)a|b)+$/
  4331. \= Expect no match
  4332. a
  4333. /A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  4334. \= Expect no match
  4335. AAAC
  4336. /^((abc|abcx)(*THEN)y|abcd)/
  4337. abcd
  4338. \= Expect no match
  4339. abcxy
  4340. /^((yes|no)(*THEN)(*F))?/
  4341. \= Expect no match
  4342. yes
  4343. /(A (.*) C? (*THEN) | A D) (*FAIL)/x
  4344. \= Expect no match
  4345. AbcdCBefgBhiBqz
  4346. /(A (.*) C? (*THEN) | A D) z/x
  4347. \= Expect no match
  4348. AbcdCBefgBhiBqz
  4349. /(A (.*) C? (*THEN) | A D) \s* (*FAIL)/x
  4350. \= Expect no match
  4351. AbcdCBefgBhiBqz
  4352. /(A (.*) C? (*THEN) | A D) \s* z/x
  4353. \= Expect no match
  4354. AbcdCBefgBhiBqz
  4355. /(A (.*) (?:C|) (*THEN) | A D) (*FAIL)/x
  4356. \= Expect no match
  4357. AbcdCBefgBhiBqz
  4358. /(A (.*) (?:C|) (*THEN) | A D) z/x
  4359. \= Expect no match
  4360. AbcdCBefgBhiBqz
  4361. /(A (.*) C{0,6} (*THEN) | A D) (*FAIL)/x
  4362. \= Expect no match
  4363. AbcdCBefgBhiBqz
  4364. /(A (.*) C{0,6} (*THEN) | A D) z/x
  4365. \= Expect no match
  4366. AbcdCBefgBhiBqz
  4367. /(A (.*) (CE){0,6} (*THEN) | A D) (*FAIL)/x
  4368. \= Expect no match
  4369. AbcdCEBefgBhiBqz
  4370. /(A (.*) (CE){0,6} (*THEN) | A D) z/x
  4371. \= Expect no match
  4372. AbcdCEBefgBhiBqz
  4373. /(A (.*) (CE*){0,6} (*THEN) | A D) (*FAIL)/x
  4374. \= Expect no match
  4375. AbcdCBefgBhiBqz
  4376. /(A (.*) (CE*){0,6} (*THEN) | A D) z/x
  4377. \= Expect no match
  4378. AbcdCBefgBhiBqz
  4379. /(?=a(*COMMIT)b|ac)ac|ac/
  4380. \= Expect no match
  4381. ac
  4382. /(?=a(*COMMIT)b|(ac)) ac | (a)c/x
  4383. \= Expect no match
  4384. ac
  4385. # ----
  4386. /(?(?!b(*THEN)a)bn|bnn)/
  4387. bnn
  4388. /(?!b(*SKIP)a)bn|bnn/
  4389. bnn
  4390. /(?(?!b(*SKIP)a)bn|bnn)/
  4391. bnn
  4392. /(?!b(*PRUNE)a)bn|bnn/
  4393. bnn
  4394. /(?(?!b(*PRUNE)a)bn|bnn)/
  4395. bnn
  4396. /(?!b(*COMMIT)a)bn|bnn/
  4397. bnn
  4398. /(?(?!b(*COMMIT)a)bn|bnn)/
  4399. bnn
  4400. /(?=b(*SKIP)a)bn|bnn/
  4401. \= Expect no match
  4402. bnn
  4403. /(?=b(*THEN)a)bn|bnn/
  4404. bnn
  4405. /^(?!a(*SKIP)b)/
  4406. ac
  4407. /^(?!a(*SKIP)b)../
  4408. acd
  4409. /(?!a(*SKIP)b)../
  4410. acd
  4411. /^(?(?!a(*SKIP)b))/
  4412. ac
  4413. /^(?!a(*PRUNE)b)../
  4414. acd
  4415. /(?!a(*PRUNE)b)../
  4416. acd
  4417. /(?!a(*COMMIT)b)ac|cd/
  4418. ac
  4419. /\A.*?(?:a|bc)/
  4420. ba
  4421. /^(A(*THEN)B|C(*THEN)D)/
  4422. CD
  4423. /(*:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4424. abc
  4425. /(*PRUNE:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4426. abc
  4427. /(*SKIP:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4428. abc
  4429. /(*THEN:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4430. abc
  4431. /^\d*\w{4}/
  4432. 1234
  4433. \= Expect no match
  4434. 123
  4435. /^[^b]*\w{4}/
  4436. aaaa
  4437. \= Expect no match
  4438. aaa
  4439. /^[^b]*\w{4}/i
  4440. aaaa
  4441. \= Expect no match
  4442. aaa
  4443. /^a*\w{4}/
  4444. aaaa
  4445. \= Expect no match
  4446. aaa
  4447. /^a*\w{4}/i
  4448. aaaa
  4449. \= Expect no match
  4450. aaa
  4451. /(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  4452. foofoo
  4453. barbar
  4454. /(?<n>A)(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  4455. AfooA
  4456. AbarA
  4457. \= Expect no match
  4458. Afoofoo
  4459. Abarbar
  4460. /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
  4461. 1 IN SOA non-sp1 non-sp2(
  4462. /^ (?:(?<A>A)|(?'B'B)(?<A>A)) (?('A')x) (?(<B>)y)$/x,dupnames
  4463. Ax
  4464. BAxy
  4465. /^A\xZ/
  4466. A\0Z
  4467. /^A\o{123}B/
  4468. A\123B
  4469. / ^ a + + b $ /x
  4470. aaaab
  4471. / ^ a + #comment
  4472. + b $ /x
  4473. aaaab
  4474. / ^ a + #comment
  4475. #comment
  4476. + b $ /x
  4477. aaaab
  4478. / ^ (?> a + ) b $ /x
  4479. aaaab
  4480. / ^ ( a + ) + + \w $ /x
  4481. aaaab
  4482. /(?:a\Kb)*+/aftertext
  4483. ababc
  4484. /(?>a\Kb)*/aftertext
  4485. ababc
  4486. /(?:a\Kb)*/aftertext
  4487. ababc
  4488. /(a\Kb)*+/aftertext
  4489. ababc
  4490. /(a\Kb)*/aftertext
  4491. ababc
  4492. /(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
  4493. \= Expect no match
  4494. acb
  4495. /\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++/
  4496. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4497. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++/
  4498. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4499. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")++\")++/
  4500. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4501. /\A([^\"1]++|[\"2]([^\"3]*+|[\"4][\"5])*+[\"6])++/
  4502. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4503. /^\w+(?>\s*)(?<=\w)/
  4504. test test
  4505. /(?P<same>a)(?P<same>b)/g,dupnames
  4506. abbaba
  4507. /(?P<same>a)(?P<same>b)(?P=same)/g,dupnames
  4508. abbaba
  4509. /(?P=same)?(?P<same>a)(?P<same>b)/g,dupnames
  4510. abbaba
  4511. /(?:(?P=same)?(?:(?P<same>a)|(?P<same>b))(?P=same))+/g,dupnames
  4512. bbbaaabaabb
  4513. /(?:(?P=same)?(?:(?P=same)(?P<same>a)(?P=same)|(?P=same)?(?P<same>b)(?P=same)){2}(?P=same)(?P<same>c)(?P=same)){2}(?P<same>z)?/g,dupnames
  4514. \= Expect no match
  4515. bbbaaaccccaaabbbcc
  4516. /(?P<Name>a)?(?P<Name2>b)?(?(<Name>)c|d)*l/
  4517. acl
  4518. bdl
  4519. adl
  4520. bcl
  4521. /\sabc/
  4522. \x{0b}abc
  4523. /[\Qa]\E]+/
  4524. aa]]
  4525. /[\Q]a\E]+/
  4526. aa]]
  4527. /A((((((((a))))))))\8B/
  4528. AaaB
  4529. /A(((((((((a)))))))))\9B/
  4530. AaaB
  4531. /A[\8\9]B/
  4532. A8B
  4533. A9B
  4534. /(|ab)*?d/
  4535. abd
  4536. xyd
  4537. /(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
  4538. 1234abcd
  4539. /(\2|a)(\1)/
  4540. aaa
  4541. /(\2)(\1)/
  4542. /Z*(|d*){216}/
  4543. /(?1)(?#?'){8}(a)/
  4544. baaaaaaaaac
  4545. /((((((((((((x))))))))))))\12/
  4546. xx
  4547. /A[\8]B[\9]C/
  4548. A8B9C
  4549. /(?1)()((((((\1++))\x85)+)|))/
  4550. \x85\x85
  4551. /(?|(\k'Pm')|(?'Pm'))/
  4552. abcd
  4553. /(?|(aaa)|(b))\g{1}/
  4554. aaaaaa
  4555. bb
  4556. /(?|(aaa)|(b))(?1)/
  4557. aaaaaa
  4558. baaa
  4559. \= Expect no match
  4560. bb
  4561. /(?|(aaa)|(b))/
  4562. xaaa
  4563. xbc
  4564. /(?|(?'a'aaa)|(?'a'b))\k'a'/
  4565. aaaaaa
  4566. bb
  4567. /(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/dupnames
  4568. aaaccccaaa
  4569. bccccb
  4570. # /x does not apply to MARK labels
  4571. /x (*MARK:ab cd # comment
  4572. ef) x/x,mark
  4573. axxz
  4574. /(?<=a(B){0}c)X/
  4575. acX
  4576. /(?<DEFINE>b)(?(DEFINE)(a+))(?&DEFINE)/
  4577. bbbb
  4578. \= Expect no match
  4579. baaab
  4580. /(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])/
  4581. \ Fred:099
  4582. /(?=.*X)X$/
  4583. \ X
  4584. /(?s)(?=.*?)b/
  4585. aabc
  4586. /(Z)(a)\2{1,2}?(?-i)\1X/i
  4587. ZaAAZX
  4588. /(?'c')XX(?'YYYYYYYYYYYYYYYYYYYYYYYCl')/
  4589. /[s[:digit:]\E-H]+/
  4590. s09-H
  4591. /[s[:digit:]\Q\E-H]+/
  4592. s09-H
  4593. /a+(?:|b)a/
  4594. aaaa
  4595. /X?(R||){3335}/
  4596. /(?1)(A(*COMMIT)|B)D/
  4597. ABD
  4598. XABD
  4599. BAD
  4600. ABXABD
  4601. \= Expect no match
  4602. ABX
  4603. /(?(DEFINE)(?<m> 1? (?=(?<cond>2)?) 1 2 (?('cond')|3)))
  4604. \A
  4605. ()
  4606. (?&m)
  4607. \Z/x
  4608. 123
  4609. /^(?:
  4610. (?: A| (1? (?=(?<cond>2)?) (1) 2 (?('cond')|3)) )
  4611. (Z)
  4612. )+$/x
  4613. AZ123Z
  4614. \= Expect no match
  4615. AZ12Z
  4616. /^ (?(DEFINE) ( (?!(a)\2b)..) ) ()(?1) /x
  4617. acb
  4618. \= Expect no match
  4619. aab
  4620. /(?>ab|abab){1,5}?M/
  4621. abababababababababababM
  4622. /(?>ab|abab){2}?M/
  4623. abababM
  4624. /((?(?=(a))a)+k)/
  4625. bbak
  4626. /((?(?=(a))a|)+k)/
  4627. bbak
  4628. /(?(?!(b))a|b)+k/
  4629. ababbalbbadabak
  4630. /(?!(b))c|b/
  4631. Ab
  4632. Ac
  4633. /(?=(b))b|c/
  4634. Ab
  4635. Ac
  4636. /^(.|(.)(?1)\2)$/
  4637. a
  4638. aba
  4639. abcba
  4640. ababa
  4641. abcdcba
  4642. /^((.)(?1)\2|.?)$/
  4643. a
  4644. aba
  4645. abba
  4646. abcba
  4647. ababa
  4648. abccba
  4649. abcdcba
  4650. abcddcba
  4651. /^(.)(\1|a(?2))/
  4652. bab
  4653. /^(.|(.)(?1)?\2)$/
  4654. abcba
  4655. /^(?(?=(a))abc|def)/
  4656. abc
  4657. /^(?(?!(a))def|abc)/
  4658. abc
  4659. /^(?(?=(a)(*ACCEPT))abc|def)/
  4660. abc
  4661. /^(?(?!(a)(*ACCEPT))def|abc)/
  4662. abc
  4663. /^(?1)\d{3}(a)/
  4664. a123a
  4665. # This pattern uses a lot of named subpatterns in order to match email
  4666. # addresses in various formats. It's a heavy test for named subpatterns. In the
  4667. # <atext> group, slash is coded as \x{2f} so that this pattern can also be
  4668. # processed by perltest.sh, which does not cater for an escaped delimiter
  4669. # within the pattern. $ within the pattern must also be escaped. All $ and @
  4670. # characters in subject strings are escaped so that Perl doesn't interpret them
  4671. # as variable insertions and " characters must also be escaped for Perl.
  4672. # This set of subpatterns is more or less a direct transliteration of the BNF
  4673. # definitions in RFC2822, without any of the obsolete features. The addition of
  4674. # a possessive + to the definition of <phrase> reduced the match limit in PCRE2
  4675. # from over 5 million to just under 400, and eliminated a very noticeable delay
  4676. # when this file was passed to perltest.sh.
  4677. /(?ix)(?(DEFINE)
  4678. (?<addr_spec> (?&local_part) \@ (?&domain) )
  4679. (?<angle_addr> (?&CFWS)?+ < (?&addr_spec) > (?&CFWS)?+ )
  4680. (?<atext> [a-z\d!#\$%&'*+-\x{2f}=?^_`{|}~] )
  4681. (?<atom> (?&CFWS)?+ (?&atext)+ (?&CFWS)?+ )
  4682. (?<ccontent> (?&ctext) | (?&quoted_pair) | (?&comment) )
  4683. (?<ctext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ ()\\] )
  4684. (?<comment> \( (?: (?&FWS)?+ (?&ccontent) )*+ (?&FWS)?+ \) )
  4685. (?<CFWS> (?: (?&FWS)?+ (?&comment) )* (?# NOT possessive)
  4686. (?: (?&FWS)?+ (?&comment) | (?&FWS) ) )
  4687. (?<dcontent> (?&dtext) | (?&quoted_pair) )
  4688. (?<display_name> (?&phrase) )
  4689. (?<domain> (?&dot_atom) | (?&domain_literal) )
  4690. (?<domain_literal> (?&CFWS)?+ \[ (?: (?&FWS)?+ (?&dcontent) )* (?&FWS)?+ \]
  4691. (?&CFWS)?+ )
  4692. (?<dot_atom> (?&CFWS)?+ (?&dot_atom_text) (?&CFWS)?+ )
  4693. (?<dot_atom_text> (?&atext)++ (?: \. (?&atext)++)*+ )
  4694. (?<dtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ \[\]\\] )
  4695. (?<FWS> (?: [\t\ ]*+ \n)?+ [\t\ ]++ )
  4696. (?<local_part> (?&dot_atom) | (?&quoted_string) )
  4697. (?<mailbox> (?&name_addr) | (?&addr_spec) )
  4698. (?<name_addr> (?&display_name)? (?&angle_addr) )
  4699. (?<phrase> (?&word)++ )
  4700. (?<qcontent> (?&qtext) | (?&quoted_pair) )
  4701. (?<quoted_pair> " (?&text) )
  4702. (?<quoted_string> (?&CFWS)?+ " (?: (?&FWS)?+ (?&qcontent))* (?&FWS)?+ "
  4703. (?&CFWS)?+ )
  4704. (?<qtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ "\\] )
  4705. (?<text> [^\r\n] )
  4706. (?<word> (?&atom) | (?&quoted_string) )
  4707. ) # End DEFINE
  4708. ^(?&mailbox)$/
  4709. Alan Other <user\@dom.ain>
  4710. <user\@dom.ain>
  4711. user\@dom.ain
  4712. user\@[]
  4713. user\@[domain literal]
  4714. user\@[domain literal with \"[square brackets\"] inside]
  4715. \"A. Other\" <user.1234\@dom.ain> (a comment)
  4716. A. Other <user.1234\@dom.ain> (a comment)
  4717. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  4718. \= Expect no match
  4719. A missing angle <user\@some.where
  4720. The quick brown fox
  4721. # --------------------------------------------------------------------------
  4722. # This pattern uses named groups to match default PCRE2 patterns. It's another
  4723. # heavy test for named subpatterns. Once again, code slash as \x{2f} and escape
  4724. # $ even in classes so that this works with pcre2test.
  4725. /(?sx)(?(DEFINE)
  4726. (?<assertion> (?&simple_assertion) | (?&lookaround) )
  4727. (?<atomic_group> \( \? > (?&regex) \) )
  4728. (?<back_reference> \\ \d+ |
  4729. \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) |
  4730. \\k <(?&groupname)> |
  4731. \\k '(?&groupname)' |
  4732. \\k \{ (?&groupname) \} |
  4733. \( \? P= (?&groupname) \) )
  4734. (?<branch> (?:(?&assertion) |
  4735. (?&callout) |
  4736. (?&comment) |
  4737. (?&option_setting) |
  4738. (?&qualified_item) |
  4739. (?&quoted_string) |
  4740. (?&quoted_string_empty) |
  4741. (?&special_escape) |
  4742. (?&verb)
  4743. )* )
  4744. (?<callout> \(\?C (?: \d+ |
  4745. (?: (?<D>["'`^%\#\$])
  4746. (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' |
  4747. \{ (?: \}\} | [^}]*+ )* \} )
  4748. )? \) )
  4749. (?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )?
  4750. (?&regex) \) )
  4751. (?<character_class> \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )
  4752. (?<character_type> (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )
  4753. (?<class_item> (?: \[ : (?:
  4754. alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|
  4755. punct|space|upper|word|xdigit
  4756. ) : \] |
  4757. (?&quoted_string) |
  4758. (?&quoted_string_empty) |
  4759. (?&escaped_character) |
  4760. (?&character_type) |
  4761. [^]] ) )
  4762. (?<comment> \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )
  4763. (?<condition> (?: \( [+-]? \d+ \) |
  4764. \( < (?&groupname) > \) |
  4765. \( ' (?&groupname) ' \) |
  4766. \( R \d* \) |
  4767. \( R & (?&groupname) \) |
  4768. \( (?&groupname) \) |
  4769. \( DEFINE \) |
  4770. \( VERSION >?=\d+(?:\.\d\d?)? \) |
  4771. (?&callout)?+ (?&comment)* (?&lookaround) ) )
  4772. (?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )
  4773. (?<delimited_regex> (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex)
  4774. \k'delimiter' .* )
  4775. (?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} |
  4776. x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} |
  4777. [aefnrt] | c[[:print:]] |
  4778. [^[:alnum:]] ) )
  4779. (?<group> (?&capturing_group) | (?&non_capturing_group) |
  4780. (?&resetting_group) | (?&atomic_group) |
  4781. (?&conditional_group) )
  4782. (?<groupname> [a-zA-Z_]\w* )
  4783. (?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )
  4784. (?<lookaround> \(\? (?: = | ! | <= | <! ) (?&regex) \) )
  4785. (?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )
  4786. (?<option_setting> \(\? [iJmnsUx-]* \) )
  4787. (?<qualified_item> (?:\. |
  4788. (?&lookaround) |
  4789. (?&back_reference) |
  4790. (?&character_class) |
  4791. (?&character_type) |
  4792. (?&escaped_character) |
  4793. (?&group) |
  4794. (?&subroutine_call) |
  4795. (?&literal_character) |
  4796. (?&quoted_string)
  4797. ) (?&comment)? (?&qualifier)? )
  4798. (?<qualifier> (?: [?*+] | (?&range_qualifier) ) [+?]? )
  4799. (?<quoted_string> (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) )
  4800. (?<quoted_string_empty> \\Q\\E )
  4801. (?<range_qualifier> \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )
  4802. (?<regex> (?&start_item)* (?&branch) (?: \| (?&branch) )* )
  4803. (?<resetting_group> \( \? \| (?&regex) \) )
  4804. (?<simple_assertion> \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )
  4805. (?<special_escape> \\K )
  4806. (?<start_item> \( \* (?:
  4807. ANY |
  4808. ANYCRLF |
  4809. BSR_ANYCRLF |
  4810. BSR_UNICODE |
  4811. CR |
  4812. CRLF |
  4813. LF |
  4814. LIMIT_MATCH=\d+ |
  4815. LIMIT_DEPTH=\d+ |
  4816. LIMIT_HEAP=\d+ |
  4817. NOTEMPTY |
  4818. NOTEMPTY_ATSTART |
  4819. NO_AUTO_POSSESS |
  4820. NO_DOTSTAR_ANCHOR |
  4821. NO_JIT |
  4822. NO_START_OPT |
  4823. NUL |
  4824. UTF |
  4825. UCP ) \) )
  4826. (?<subroutine_call> (?: \(\?R\) | \(\?[+-]?\d+\) |
  4827. \(\? (?: & | P> ) (?&groupname) \) |
  4828. \\g < (?&groupname) > |
  4829. \\g ' (?&groupname) ' |
  4830. \\g < [+-]? \d+ > |
  4831. \\g ' [+-]? \d+ ) )
  4832. (?<verb> \(\* (?: ACCEPT | FAIL | F | COMMIT |
  4833. (?:MARK)?:(?&verbname) |
  4834. (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )
  4835. (?<verbname> [^)]+ )
  4836. ) # End DEFINE
  4837. # Kick it all off...
  4838. ^(?&delimited_regex)$/subject_literal,jitstack=256
  4839. /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
  4840. /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
  4841. /^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/
  4842. /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
  4843. /<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is
  4844. /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /
  4845. /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  4846. /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  4847. /^(\w++|\s++)*$/
  4848. /a+b?(*THEN)c+(*FAIL)/
  4849. /(A (A|B(*ACCEPT)|C) D)(E)/x
  4850. /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  4851. /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
  4852. /(?C`a``b`)(?C'a''b')(?C"a""b")(?C^a^^b^)(?C%a%%b%)(?C#a##b#)(?C$a$$b$)(?C{a}}b})/B,callout_info
  4853. /(?sx)(?(DEFINE)(?<assertion> (?&simple_assertion) | (?&lookaround) )(?<atomic_group> \( \? > (?&regex) \) )(?<back_reference> \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) )(?<branch> (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?&quoted_string) | (?&quoted_string_empty) | (?&special_escape) | (?&verb) )* )(?<callout> \(\?C (?: \d+ | (?: (?<D>["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) )(?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?&regex) \) )(?<character_class> \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )(?<character_type> (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )(?<class_item> (?: \[ : (?: alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print| punct|space|upper|word|xdigit ) : \] | (?&quoted_string) | (?&quoted_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) )(?<comment> \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )(?<condition> (?: \( [+-]? \d+ \) | \( < (?&groupname) > \) | \( ' (?&groupname) ' \) | \( R \d* \) | \( R & (?&groupname) \) | \( (?&groupname) \) | \( DEFINE \) | \( VERSION >?=\d+(?:\.\d\d?)? \) | (?&callout)?+ (?&comment)* (?&lookaround) ) )(?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )(?<delimited_regex> (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex) \k'delimiter' .* )(?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} | x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} | [aefnrt] | c[[:print:]] | [^[:alnum:]] ) )(?<group> (?&capturing_group) | (?&non_capturing_group) | (?&resetting_group) | (?&atomic_group) | (?&conditional_group) )(?<groupname> [a-zA-Z_]\w* )(?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )(?<lookaround> \(\? (?: = | ! | <= | <! ) (?&regex) \) )(?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )(?<option_setting> \(\? [iJmnsUx-]* \) )(?<qualified_item> (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?&quoted_string) ) (?&comment)? (?&qualifier)? )(?<qualifier> (?: [?*+] | (?&range_qualifier) ) [+?]? )(?<quoted_string> (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) ) (?<quoted_string_empty> \\Q\\E ) (?<range_qualifier> \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )(?<regex> (?&start_item)* (?&branch) (?: \| (?&branch) )* )(?<resetting_group> \( \? \| (?&regex) \) )(?<simple_assertion> \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )(?<special_escape> \\K )(?<start_item> \( \* (?: ANY | ANYCRLF | BSR_ANYCRLF | BSR_UNICODE | CR | CRLF | LF | LIMIT_MATCH=\d+ | LIMIT_DEPTH=\d+ | LIMIT_HEAP=\d+ | NOTEMPTY | NOTEMPTY_ATSTART | NO_AUTO_POSSESS | NO_DOTSTAR_ANCHOR | NO_JIT | NO_START_OPT | NUL | UTF | UCP ) \) )(?<subroutine_call> (?: \(\?R\) | \(\?[+-]?\d+\) | \(\? (?: & | P> ) (?&groupname) \) | \\g < (?&groupname) > | \\g ' (?&groupname) ' | \\g < [+-]? \d+ > | \\g ' [+-]? \d+ ) )(?<verb> \(\* (?: ACCEPT | FAIL | F | COMMIT | (?:MARK)?:(?&verbname) | (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )(?<verbname> [^)]+ ))^(?&delimited_regex)$/
  4854. \= Expect no match
  4855. /((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
  4856. /(?:(?(2y)a|b)(X))+/
  4857. /a(*MARK)b/
  4858. /a(*CR)b/
  4859. /(?P<abn>(?P=abn)(?<badstufxxx)/
  4860. # --------------------------------------------------------------------------
  4861. /<(?x:[a b])>/xx
  4862. < >
  4863. /<(?:[a b])>/xx
  4864. < >
  4865. /<(?xxx:[a b])>/
  4866. < >
  4867. /<(?-x:[a b])>/xx
  4868. < >
  4869. /[[:digit:]-]+/
  4870. 12-24
  4871. /((?<=((*ACCEPT)) )\1?\b) /
  4872. \= Expect no match
  4873. ((?<=((*ACCEPT)) )\\1?\\b)\x20
  4874. /((?<=((*ACCEPT))X)\1?Y)\1/
  4875. XYYZ
  4876. /((?<=((*ACCEPT))X)\1?Y(*ACCEPT))\1/
  4877. XYYZ
  4878. /(?(DEFINE)(?<optional_a>a?)X)^(?&optional_a)a$/
  4879. aa
  4880. a
  4881. /^(a?)b(?1)a/
  4882. abaa
  4883. aba
  4884. baa
  4885. ba
  4886. /^(a?)+b(?1)a/
  4887. abaa
  4888. aba
  4889. baa
  4890. ba
  4891. /^(a?)++b(?1)a/
  4892. abaa
  4893. aba
  4894. baa
  4895. ba
  4896. /^(a?)+b/
  4897. b
  4898. ab
  4899. aaab
  4900. /(?=a+)a(a+)++b/
  4901. aab
  4902. /(?<=\G.)/g,aftertext
  4903. abc
  4904. /(?<=(?=.)?)/
  4905. /(?<=(?=.)?+)/
  4906. /(?<=(?=.)*)/
  4907. /(?<=(?=.){4,5})/
  4908. /(?<=(?=.){4,5}x)/
  4909. /a(?=.(*:X))(*SKIP:X)(*F)|(.)/
  4910. abc
  4911. /a(?>(*:X))(*SKIP:X)(*F)|(.)/
  4912. abc
  4913. /a(?:(*:X))(*SKIP:X)(*F)|(.)/
  4914. abc
  4915. #pattern no_start_optimize
  4916. /(?>a(*:1))(?>b(*:1))(*SKIP:1)x|.*/
  4917. abc
  4918. /(?>a(*:1))(?>b)(*SKIP:1)x|.*/
  4919. abc
  4920. #subject mark
  4921. /a(*ACCEPT:X)b/
  4922. abc
  4923. /(?=a(*ACCEPT:QQ)bc)axyz/
  4924. axyz
  4925. /(?(DEFINE)(a(*ACCEPT:X)))(?1)b/
  4926. abc
  4927. /a(*F:X)b/
  4928. abc
  4929. /(?(DEFINE)(a(*F:X)))(?1)b/
  4930. abc
  4931. /a(*COMMIT:X)b/
  4932. abc
  4933. /(?(DEFINE)(a(*COMMIT:X)))(?1)b/
  4934. abc
  4935. /a+(*:Z)b(*COMMIT:X)(*SKIP:Z)c|.*/
  4936. aaaabd
  4937. /a+(*:Z)b(*COMMIT:X)(*SKIP:X)c|.*/
  4938. aaaabd
  4939. /a(*COMMIT:X)b/
  4940. axabc
  4941. #pattern -no_start_optimize
  4942. #subject -mark
  4943. /(.COMMIT)(*COMMIT::::::::::interal error:::)/
  4944. /(*COMMIT:ÿÿ)/
  4945. /(*COMMIT:]w)/
  4946. /(?i)A(?^)B(?^x:C D)(?^i)e f/
  4947. aBCDE F
  4948. \= Expect no match
  4949. aBCDEF
  4950. AbCDe f
  4951. /(*pla:foo).{6}/
  4952. abcfoobarxyz
  4953. \= Expect no match
  4954. abcfooba
  4955. /(*positive_lookahead:foo).{6}/
  4956. abcfoobarxyz
  4957. /(?(*pla:foo).{6}|a..)/
  4958. foobarbaz
  4959. abcfoobar
  4960. /(?(*positive_lookahead:foo).{6}|a..)/
  4961. foobarbaz
  4962. abcfoobar
  4963. /(*plb:foo)bar/
  4964. abcfoobar
  4965. \= Expect no match
  4966. abcbarfoo
  4967. /(*positive_lookbehind:foo)bar/
  4968. abcfoobar
  4969. \= Expect no match
  4970. abcbarfoo
  4971. /(?(*plb:foo)bar|baz)/
  4972. abcfoobar
  4973. bazfoobar
  4974. abcbazfoobar
  4975. foobazfoobar
  4976. /(?(*positive_lookbehind:foo)bar|baz)/
  4977. abcfoobar
  4978. bazfoobar
  4979. abcbazfoobar
  4980. foobazfoobar
  4981. /(*nlb:foo)bar/
  4982. abcbarfoo
  4983. \= Expect no match
  4984. abcfoobar
  4985. /(*negative_lookbehind:foo)bar/
  4986. abcbarfoo
  4987. \= Expect no match
  4988. abcfoobar
  4989. /(?(*nlb:foo)bar|baz)/
  4990. abcfoobaz
  4991. abcbarbaz
  4992. \= Expect no match
  4993. abcfoobar
  4994. /(?(*negative_lookbehind:foo)bar|baz)/
  4995. abcfoobaz
  4996. abcbarbaz
  4997. \= Expect no match
  4998. abcfoobar
  4999. /(*atomic:a+)\w/
  5000. aaab
  5001. \= Expect no match
  5002. aaaa
  5003. / (?<word> \w+ )* \. /xi
  5004. pokus.
  5005. /(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
  5006. pokus.
  5007. /(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
  5008. pokus.
  5009. /(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
  5010. pokus.
  5011. /(?&word)* \. (?<word> \w+ )/xi
  5012. pokus.hokus
  5013. /a(?(?=(*:2)b).)/mark
  5014. abc
  5015. acb
  5016. /a(?(?!(*:2)b).)/mark
  5017. acb
  5018. abc
  5019. /(?:a|ab){1}+c/
  5020. \= Expect no match
  5021. abc
  5022. /(a|ab){1}+c/
  5023. abc
  5024. /(a+){1}+a/
  5025. \= Expect no match
  5026. aaaa
  5027. /(?(DEFINE)(a|ab))(?1){1}+c/
  5028. abc
  5029. /(?:a|(?=b)|.)*\z/
  5030. abc
  5031. /(?:a|(?=b)|.)*/
  5032. abc
  5033. /(?<=a(*SKIP)x)|c/
  5034. abcd
  5035. /(?<=a(*SKIP)x)|d/
  5036. abcd
  5037. /(?<=(?=.(?<=x)))/aftertext
  5038. abx
  5039. /(?<=(?=(?<=a)))b/
  5040. ab
  5041. /^(?<A>a)(?(<A>)b)((?<=b).*)$/
  5042. abc
  5043. /^(a\1?){4}$/
  5044. aaaa
  5045. aaaaaa
  5046. /^((\1+)|\d)+133X$/
  5047. 111133X
  5048. /^(?=.*(?=(([A-Z]).*(?(1)\1)))(?!.+\2)){26}/i
  5049. The quick brown fox jumps over the lazy dog.
  5050. Jackdaws love my big sphinx of quartz.
  5051. Pack my box with five dozen liquor jugs.
  5052. \= Expect no match
  5053. The quick brown fox jumps over the lazy cat.
  5054. Hackdaws love my big sphinx of quartz.
  5055. Pack my fox with five dozen liquor jugs.
  5056. /^(?>.*?([A-Z])(?!.*\1)){26}/i
  5057. The quick brown fox jumps over the lazy dog.
  5058. Jackdaws love my big sphinx of quartz.
  5059. Pack my box with five dozen liquor jugs.
  5060. \= Expect no match
  5061. The quick brown fox jumps over the lazy cat.
  5062. Hackdaws love my big sphinx of quartz.
  5063. Pack my fox with five dozen liquor jugs.
  5064. /(?<=X(?(DEFINE)(A)))X(*F)/
  5065. \= Expect no match
  5066. AXYZ
  5067. /(?<=X(?(DEFINE)(A)))./
  5068. AXYZ
  5069. /(?<=X(?(DEFINE)(.*))Y)./
  5070. AXYZ
  5071. /(?<=X(?(DEFINE)(Y))(?1))./
  5072. AXYZ
  5073. /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/
  5074. word
  5075. /a{1,2,3}b/
  5076. a{1,2,3}b
  5077. /\214748364/
  5078. >\x{8c}748364<
  5079. /a{65536/
  5080. >a{65536<
  5081. /a\K.(?0)*/
  5082. abac
  5083. /(a\K.(?1)*)/
  5084. abac
  5085. # End of testinput1