testinput1 122 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657
  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. /a(?:b|c|d){6,7}(.)/
  2615. acdbcdbe
  2616. /a(?:b|c|d){6,7}?(.)/
  2617. acdbcdbe
  2618. /a(?:b|c|d){5,6}(.)/
  2619. acdbcdbe
  2620. /a(?:b|c|d){5,6}?(.)/
  2621. acdbcdbe
  2622. /a(?:b|c|d){5,7}(.)/
  2623. acdbcdbe
  2624. /a(?:b|c|d){5,7}?(.)/
  2625. acdbcdbe
  2626. /a(?:b|(c|e){1,2}?|d)+?(.)/
  2627. ace
  2628. /^(.+)?B/
  2629. AB
  2630. /^([^a-z])|(\^)$/
  2631. .
  2632. /^[<>]&/
  2633. <&OUT
  2634. /^(a\1?){4}$/
  2635. aaaaaaaaaa
  2636. \= Expect no match
  2637. AB
  2638. aaaaaaaaa
  2639. aaaaaaaaaaa
  2640. /^(a(?(1)\1)){4}$/
  2641. aaaaaaaaaa
  2642. \= Expect no match
  2643. aaaaaaaaa
  2644. aaaaaaaaaaa
  2645. /(?<=a)b/
  2646. ab
  2647. \= Expect no match
  2648. cb
  2649. b
  2650. /(?<!c)b/
  2651. ab
  2652. b
  2653. b
  2654. /(?:..)*a/
  2655. aba
  2656. /(?:..)*?a/
  2657. aba
  2658. /^(?:b|a(?=(.)))*\1/
  2659. abc
  2660. /^(){3,5}/
  2661. abc
  2662. /^(a+)*ax/
  2663. aax
  2664. /^((a|b)+)*ax/
  2665. aax
  2666. /^((a|bc)+)*ax/
  2667. aax
  2668. /(a|x)*ab/
  2669. cab
  2670. /(a)*ab/
  2671. cab
  2672. /(?:(?i)a)b/
  2673. ab
  2674. /((?i)a)b/
  2675. ab
  2676. /(?:(?i)a)b/
  2677. Ab
  2678. /((?i)a)b/
  2679. Ab
  2680. /(?:(?i)a)b/
  2681. \= Expect no match
  2682. cb
  2683. aB
  2684. /((?i)a)b/
  2685. /(?i:a)b/
  2686. ab
  2687. /((?i:a))b/
  2688. ab
  2689. /(?i:a)b/
  2690. Ab
  2691. /((?i:a))b/
  2692. Ab
  2693. /(?i:a)b/
  2694. \= Expect no match
  2695. aB
  2696. aB
  2697. /((?i:a))b/
  2698. /(?:(?-i)a)b/i
  2699. ab
  2700. /((?-i)a)b/i
  2701. ab
  2702. /(?:(?-i)a)b/i
  2703. aB
  2704. /((?-i)a)b/i
  2705. aB
  2706. /(?:(?-i)a)b/i
  2707. aB
  2708. \= Expect no match
  2709. Ab
  2710. AB
  2711. /(?-i:a)b/i
  2712. ab
  2713. /((?-i:a))b/i
  2714. ab
  2715. /(?-i:a)b/i
  2716. aB
  2717. /((?-i:a))b/i
  2718. aB
  2719. /(?-i:a)b/i
  2720. \= Expect no match
  2721. AB
  2722. Ab
  2723. /((?-i:a))b/i
  2724. /(?-i:a)b/i
  2725. aB
  2726. /((?-i:a))b/i
  2727. aB
  2728. /(?-i:a)b/i
  2729. \= Expect no match
  2730. Ab
  2731. AB
  2732. /((?-i:a))b/i
  2733. /((?-i:a.))b/i
  2734. \= Expect no match
  2735. AB
  2736. a\nB
  2737. /((?s-i:a.))b/i
  2738. a\nB
  2739. /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
  2740. cabbbb
  2741. /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
  2742. caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  2743. /(ab)\d\1/i
  2744. Ab4ab
  2745. ab4Ab
  2746. /foo\w*\d{4}baz/
  2747. foobar1234baz
  2748. /x(~~)*(?:(?:F)?)?/
  2749. x~~
  2750. /^a(?#xxx){3}c/
  2751. aaac
  2752. /^a (?#xxx) (?#yyy) {3}c/x
  2753. aaac
  2754. /(?<![cd])b/
  2755. \= Expect no match
  2756. B\nB
  2757. dbcb
  2758. /(?<![cd])[ab]/
  2759. dbaacb
  2760. /(?<!(c|d))b/
  2761. /(?<!(c|d))[ab]/
  2762. dbaacb
  2763. /(?<!cd)[ab]/
  2764. cdaccb
  2765. /^(?:a?b?)*$/
  2766. \
  2767. a
  2768. ab
  2769. aaa
  2770. \= Expect no match
  2771. dbcb
  2772. a--
  2773. aa--
  2774. /((?s)^a(.))((?m)^b$)/
  2775. a\nb\nc\n
  2776. /((?m)^b$)/
  2777. a\nb\nc\n
  2778. /(?m)^b/
  2779. a\nb\n
  2780. /(?m)^(b)/
  2781. a\nb\n
  2782. /((?m)^b)/
  2783. a\nb\n
  2784. /\n((?m)^b)/
  2785. a\nb\n
  2786. /((?s).)c(?!.)/
  2787. a\nb\nc\n
  2788. a\nb\nc\n
  2789. /((?s)b.)c(?!.)/
  2790. a\nb\nc\n
  2791. a\nb\nc\n
  2792. /^b/
  2793. /()^b/
  2794. \= Expect no match
  2795. a\nb\nc\n
  2796. a\nb\nc\n
  2797. /((?m)^b)/
  2798. a\nb\nc\n
  2799. /(x)?(?(1)a|b)/
  2800. \= Expect no match
  2801. a
  2802. a
  2803. /(x)?(?(1)b|a)/
  2804. a
  2805. /()?(?(1)b|a)/
  2806. a
  2807. /()(?(1)b|a)/
  2808. /()?(?(1)a|b)/
  2809. a
  2810. /^(\()?blah(?(1)(\)))$/
  2811. (blah)
  2812. blah
  2813. \= Expect no match
  2814. a
  2815. blah)
  2816. (blah
  2817. /^(\(+)?blah(?(1)(\)))$/
  2818. (blah)
  2819. blah
  2820. \= Expect no match
  2821. blah)
  2822. (blah
  2823. /(?(?!a)a|b)/
  2824. /(?(?!a)b|a)/
  2825. a
  2826. /(?(?=a)b|a)/
  2827. \= Expect no match
  2828. a
  2829. a
  2830. /(?(?=a)a|b)/
  2831. a
  2832. /(?=(a+?))(\1ab)/
  2833. aaab
  2834. /^(?=(a+?))\1ab/
  2835. /(\w+:)+/
  2836. one:
  2837. /$(?<=^(a))/
  2838. a
  2839. /(?=(a+?))(\1ab)/
  2840. aaab
  2841. /^(?=(a+?))\1ab/
  2842. \= Expect no match
  2843. aaab
  2844. aaab
  2845. /([\w:]+::)?(\w+)$/
  2846. abcd
  2847. xy:z:::abcd
  2848. /^[^bcd]*(c+)/
  2849. aexycd
  2850. /(a*)b+/
  2851. caab
  2852. /([\w:]+::)?(\w+)$/
  2853. abcd
  2854. xy:z:::abcd
  2855. \= Expect no match
  2856. abcd:
  2857. abcd:
  2858. /^[^bcd]*(c+)/
  2859. aexycd
  2860. /(>a+)ab/
  2861. /(?>a+)b/
  2862. aaab
  2863. /([[:]+)/
  2864. a:[b]:
  2865. /([[=]+)/
  2866. a=[b]=
  2867. /([[.]+)/
  2868. a.[b].
  2869. /((?>a+)b)/
  2870. aaab
  2871. /(?>(a+))b/
  2872. aaab
  2873. /((?>[^()]+)|\([^()]*\))+/
  2874. ((abc(ade)ufh()()x
  2875. /a\Z/
  2876. \= Expect no match
  2877. aaab
  2878. a\nb\n
  2879. /b\Z/
  2880. a\nb\n
  2881. /b\z/
  2882. /b\Z/
  2883. a\nb
  2884. /b\z/
  2885. a\nb
  2886. /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
  2887. a
  2888. abc
  2889. a-b
  2890. 0-9
  2891. a.b
  2892. 5.6.7
  2893. the.quick.brown.fox
  2894. a100.b200.300c
  2895. 12-ab.1245
  2896. \= Expect no match
  2897. \
  2898. .a
  2899. -a
  2900. a-
  2901. a.
  2902. a_b
  2903. a.-
  2904. a..
  2905. ab..bc
  2906. the.quick.brown.fox-
  2907. the.quick.brown.fox.
  2908. the.quick.brown.fox_
  2909. the.quick.brown.fox+
  2910. /(?>.*)(?<=(abcd|wxyz))/
  2911. alphabetabcd
  2912. endingwxyz
  2913. \= Expect no match
  2914. a rather long string that doesn't end with one of them
  2915. /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
  2916. word cat dog elephant mussel cow horse canary baboon snake shark otherword
  2917. \= Expect no match
  2918. word cat dog elephant mussel cow horse canary baboon snake shark
  2919. /word (?>[a-zA-Z0-9]+ ){0,30}otherword/
  2920. \= Expect no match
  2921. 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
  2922. /(?<=\d{3}(?!999))foo/
  2923. 999foo
  2924. 123999foo
  2925. \= Expect no match
  2926. 123abcfoo
  2927. /(?<=(?!...999)\d{3})foo/
  2928. 999foo
  2929. 123999foo
  2930. \= Expect no match
  2931. 123abcfoo
  2932. /(?<=\d{3}(?!999)...)foo/
  2933. 123abcfoo
  2934. 123456foo
  2935. \= Expect no match
  2936. 123999foo
  2937. /(?<=\d{3}...)(?<!999)foo/
  2938. 123abcfoo
  2939. 123456foo
  2940. \= Expect no match
  2941. 123999foo
  2942. /<a[\s]+href[\s]*=[\s]* # find <a href=
  2943. ([\"\'])? # find single or double quote
  2944. (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
  2945. # quote, otherwise match up to next space
  2946. /isx
  2947. <a href=abcd xyz
  2948. <a href=\"abcd xyz pqr\" cats
  2949. <a href=\'abcd xyz pqr\' cats
  2950. /<a\s+href\s*=\s* # find <a href=
  2951. (["'])? # find single or double quote
  2952. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  2953. # quote, otherwise match up to next space
  2954. /isx
  2955. <a href=abcd xyz
  2956. <a href=\"abcd xyz pqr\" cats
  2957. <a href = \'abcd xyz pqr\' cats
  2958. /<a\s+href(?>\s*)=(?>\s*) # find <a href=
  2959. (["'])? # find single or double quote
  2960. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  2961. # quote, otherwise match up to next space
  2962. /isx
  2963. <a href=abcd xyz
  2964. <a href=\"abcd xyz pqr\" cats
  2965. <a href = \'abcd xyz pqr\' cats
  2966. /(Z()|A)*/
  2967. ZABCDEFG
  2968. /(Z(())|A)*/
  2969. ZABCDEFG
  2970. /((?>Z)+|A)*/
  2971. ZABCDEFG
  2972. /((?>)+|A)*/
  2973. ZABCDEFG
  2974. /a*/g
  2975. abbab
  2976. /[[:space:]]+/
  2977. > \x09\x0a\x0c\x0d\x0b<
  2978. /[[:blank:]]+/
  2979. > \x09\x0a\x0c\x0d\x0b<
  2980. /[\s]+/
  2981. > \x09\x0a\x0c\x0d\x0b<
  2982. /\s+/
  2983. > \x09\x0a\x0c\x0d\x0b<
  2984. /a b/x
  2985. ab
  2986. /(?!\A)x/m
  2987. a\nxb\n
  2988. /(?!^)x/m
  2989. \= Expect no match
  2990. a\nxb\n
  2991. /abc\Qabc\Eabc/
  2992. abcabcabc
  2993. /abc\Q(*+|\Eabc/
  2994. abc(*+|abc
  2995. / abc\Q abc\Eabc/x
  2996. abc abcabc
  2997. \= Expect no match
  2998. abcabcabc
  2999. /abc#comment
  3000. \Q#not comment
  3001. literal\E/x
  3002. abc#not comment\n literal
  3003. /abc#comment
  3004. \Q#not comment
  3005. literal/x
  3006. abc#not comment\n literal
  3007. /abc#comment
  3008. \Q#not comment
  3009. literal\E #more comment
  3010. /x
  3011. abc#not comment\n literal
  3012. /abc#comment
  3013. \Q#not comment
  3014. literal\E #more comment/x
  3015. abc#not comment\n literal
  3016. /\Qabc\$xyz\E/
  3017. abc\\\$xyz
  3018. /\Qabc\E\$\Qxyz\E/
  3019. abc\$xyz
  3020. /\Gabc/
  3021. abc
  3022. \= Expect no match
  3023. xyzabc
  3024. /\Gabc./g
  3025. abc1abc2xyzabc3
  3026. /abc./g
  3027. abc1abc2xyzabc3
  3028. /a(?x: b c )d/
  3029. XabcdY
  3030. \= Expect no match
  3031. Xa b c d Y
  3032. /((?x)x y z | a b c)/
  3033. XabcY
  3034. AxyzB
  3035. /(?i)AB(?-i)C/
  3036. XabCY
  3037. \= Expect no match
  3038. XabcY
  3039. /((?i)AB(?-i)C|D)E/
  3040. abCE
  3041. DE
  3042. \= Expect no match
  3043. abcE
  3044. abCe
  3045. dE
  3046. De
  3047. /(.*)\d+\1/
  3048. abc123abc
  3049. abc123bc
  3050. /(.*)\d+\1/s
  3051. abc123abc
  3052. abc123bc
  3053. /((.*))\d+\1/
  3054. abc123abc
  3055. abc123bc
  3056. # This tests for an IPv6 address in the form where it can have up to
  3057. # eight components, one and only one of which is empty. This must be
  3058. # an internal component.
  3059. /^(?!:) # colon disallowed at start
  3060. (?: # start of item
  3061. (?: [0-9a-f]{1,4} | # 1-4 hex digits or
  3062. (?(1)0 | () ) ) # if null previously matched, fail; else null
  3063. : # followed by colon
  3064. ){1,7} # end item; 1-7 of them required
  3065. [0-9a-f]{1,4} $ # final hex number at end of string
  3066. (?(1)|.) # check that there was an empty component
  3067. /ix
  3068. a123::a123
  3069. a123:b342::abcd
  3070. a123:b342::324e:abcd
  3071. a123:ddde:b342::324e:abcd
  3072. a123:ddde:b342::324e:dcba:abcd
  3073. a123:ddde:9999:b342::324e:dcba:abcd
  3074. \= Expect no match
  3075. 1:2:3:4:5:6:7:8
  3076. a123:bce:ddde:9999:b342::324e:dcba:abcd
  3077. a123::9999:b342::324e:dcba:abcd
  3078. abcde:2:3:4:5:6:7:8
  3079. ::1
  3080. abcd:fee0:123::
  3081. :1
  3082. 1:
  3083. /[z\Qa-d]\E]/
  3084. z
  3085. a
  3086. -
  3087. d
  3088. ]
  3089. \= Expect no match
  3090. b
  3091. /(a+)*b/
  3092. \= Expect no match
  3093. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3094. /(?i)reg(?:ul(?:[aä]|ae)r|ex)/
  3095. REGular
  3096. regulaer
  3097. Regex
  3098. regulär
  3099. /Åæåä[à-ÿÀ-ß]+/
  3100. Åæåäà
  3101. Åæåäÿ
  3102. ÅæåäÀ
  3103. Åæåäß
  3104. /(?<=Z)X./
  3105. \x84XAZXB
  3106. /ab cd (?x) de fg/
  3107. ab cd defg
  3108. /ab cd(?x) de fg/
  3109. ab cddefg
  3110. \= Expect no match
  3111. abcddefg
  3112. /(?<![^f]oo)(bar)/
  3113. foobarX
  3114. \= Expect no match
  3115. boobarX
  3116. /(?<![^f])X/
  3117. offX
  3118. \= Expect no match
  3119. onyX
  3120. /(?<=[^f])X/
  3121. onyX
  3122. \= Expect no match
  3123. offX
  3124. /^/gm
  3125. a\nb\nc\n
  3126. \
  3127. /(?<=C\n)^/gm
  3128. A\nC\nC\n
  3129. /(?:(?(1)a|b)(X))+/
  3130. bXaX
  3131. /(?:(?(1)\1a|b)(X|Y))+/
  3132. bXXaYYaY
  3133. bXYaXXaX
  3134. /()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
  3135. bXXaYYaY
  3136. /[[,abc,]+]/
  3137. abc]
  3138. a,b]
  3139. [a,b,c]
  3140. /(?-x: )/x
  3141. A\x20B
  3142. /(?x)(?-x: \s*#\s*)/
  3143. A # B
  3144. \= Expect no match
  3145. #
  3146. A s#s B
  3147. /(?x-is)(?:(?-ixs) \s*#\s*) include/
  3148. A #include
  3149. \= Expect no match
  3150. A#include
  3151. A #Include
  3152. /a*b*\w/
  3153. aaabbbb
  3154. aaaa
  3155. a
  3156. /a*b?\w/
  3157. aaabbbb
  3158. aaaa
  3159. a
  3160. /a*b{0,4}\w/
  3161. aaabbbb
  3162. aaaa
  3163. a
  3164. /a*b{0,}\w/
  3165. aaabbbb
  3166. aaaa
  3167. a
  3168. /a*\d*\w/
  3169. 0a
  3170. a
  3171. /a*b *\w/x
  3172. a
  3173. /a*b#comment
  3174. *\w/x
  3175. a
  3176. /a* b *\w/x
  3177. a
  3178. /^\w+=.*(\\\n.*)*/
  3179. abc=xyz\\\npqr
  3180. /(?=(\w+))\1:/
  3181. abcd:
  3182. /^(?=(\w+))\1:/
  3183. abcd:
  3184. /^\Eabc/
  3185. abc
  3186. /^[\Eabc]/
  3187. a
  3188. \= Expect no match
  3189. E
  3190. /^[a-\Ec]/
  3191. b
  3192. \= Expect no match
  3193. -
  3194. E
  3195. /^[a\E\E-\Ec]/
  3196. b
  3197. \= Expect no match
  3198. -
  3199. E
  3200. /^[\E\Qa\E-\Qz\E]+/
  3201. b
  3202. \= Expect no match
  3203. -
  3204. /^[a\Q]bc\E]/
  3205. a
  3206. ]
  3207. c
  3208. /^[a-\Q\E]/
  3209. a
  3210. -
  3211. /^(a()*)*/
  3212. aaaa
  3213. /^(?:a(?:(?:))*)*/
  3214. aaaa
  3215. /^(a()+)+/
  3216. aaaa
  3217. /^(?:a(?:(?:))+)+/
  3218. aaaa
  3219. /(a){0,3}(?(1)b|(c|))*D/
  3220. abbD
  3221. ccccD
  3222. D
  3223. /(a|)*\d/
  3224. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3225. \= Expect no match
  3226. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3227. /(?>a|)*\d/
  3228. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3229. \= Expect no match
  3230. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3231. /(?:a|)*\d/
  3232. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  3233. \= Expect no match
  3234. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3235. /\Z/g
  3236. abc\n
  3237. /^(?s)(?>.*)(?<!\n)/
  3238. abc
  3239. \= Expect no match
  3240. abc\n
  3241. /^(?![^\n]*\n\z)/
  3242. abc
  3243. \= Expect no match
  3244. abc\n
  3245. /\z(?<!\n)/
  3246. abc
  3247. \= Expect no match
  3248. abc\n
  3249. /(.*(.)?)*/
  3250. abcd
  3251. /( (A | (?(1)0|) )* )/x
  3252. abcd
  3253. /( ( (?(1)0|) )* )/x
  3254. abcd
  3255. /( (?(1)0|)* )/x
  3256. abcd
  3257. /[[:abcd:xyz]]/
  3258. a]
  3259. :]
  3260. /[abc[:x\]pqr]/
  3261. a
  3262. [
  3263. :
  3264. ]
  3265. p
  3266. /.*[op][xyz]/
  3267. \= Expect no match
  3268. fooabcfoo
  3269. /(?(?=.*b)b|^)/
  3270. adc
  3271. abc
  3272. /(?(?=^.*b)b|^)/
  3273. adc
  3274. \= Expect no match
  3275. abc
  3276. /(?(?=.*b)b|^)*/
  3277. adc
  3278. abc
  3279. /(?(?=.*b)b|^)+/
  3280. adc
  3281. abc
  3282. /(?(?=b).*b|^d)/
  3283. abc
  3284. /(?(?=.*b).*b|^d)/
  3285. abc
  3286. /^%((?(?=[a])[^%])|b)*%$/
  3287. %ab%
  3288. /(?i)a(?-i)b|c/
  3289. XabX
  3290. XAbX
  3291. CcC
  3292. \= Expect no match
  3293. XABX
  3294. /[\x00-\xff\s]+/
  3295. \x0a\x0b\x0c\x0d
  3296. /(abc)\1/i
  3297. \= Expect no match
  3298. abc
  3299. /(abc)\1/
  3300. \= Expect no match
  3301. abc
  3302. /[^a]*/i
  3303. 12abc
  3304. 12ABC
  3305. /[^a]*+/i
  3306. 12abc
  3307. 12ABC
  3308. /[^a]*?X/i
  3309. \= Expect no match
  3310. 12abc
  3311. 12ABC
  3312. /[^a]+?X/i
  3313. \= Expect no match
  3314. 12abc
  3315. 12ABC
  3316. /[^a]?X/i
  3317. 12aXbcX
  3318. 12AXBCX
  3319. BCX
  3320. /[^a]??X/i
  3321. 12aXbcX
  3322. 12AXBCX
  3323. BCX
  3324. /[^a]?+X/i
  3325. 12aXbcX
  3326. 12AXBCX
  3327. BCX
  3328. /[^a]{2,3}/i
  3329. abcdef
  3330. ABCDEF
  3331. /[^a]{2,3}?/i
  3332. abcdef
  3333. ABCDEF
  3334. /[^a]{2,3}+/i
  3335. abcdef
  3336. ABCDEF
  3337. /((a|)+)+Z/
  3338. Z
  3339. /(a)b|(a)c/
  3340. ac
  3341. /(?>(a))b|(a)c/
  3342. ac
  3343. /(?=(a))ab|(a)c/
  3344. ac
  3345. /((?>(a))b|(a)c)/
  3346. ac
  3347. /((?>(a))b|(a)c)++/
  3348. ac
  3349. /(?:(?>(a))b|(a)c)++/
  3350. ac
  3351. /(?=(?>(a))b|(a)c)(..)/
  3352. ac
  3353. /(?>(?>(a))b|(a)c)/
  3354. ac
  3355. /(?:(?>([ab])))+a=/aftertext
  3356. =ba=
  3357. /(?>([ab]))+a=/aftertext
  3358. =ba=
  3359. /((?>(a+)b)+(aabab))/
  3360. aaaabaaabaabab
  3361. /(?>a+|ab)+?c/
  3362. \= Expect no match
  3363. aabc
  3364. /(?>a+|ab)+c/
  3365. \= Expect no match
  3366. aabc
  3367. /(?:a+|ab)+c/
  3368. aabc
  3369. /(?(?=(a))a)/
  3370. a
  3371. /(?(?=(a))a)(b)/
  3372. ab
  3373. /^(?:a|ab)++c/
  3374. \= Expect no match
  3375. aaaabc
  3376. /^(?>a|ab)++c/
  3377. \= Expect no match
  3378. aaaabc
  3379. /^(?:a|ab)+c/
  3380. aaaabc
  3381. /(?=abc){3}abc/aftertext
  3382. abcabcabc
  3383. \= Expect no match
  3384. xyz
  3385. /(?=abc)+abc/aftertext
  3386. abcabcabc
  3387. \= Expect no match
  3388. xyz
  3389. /(?=abc)++abc/aftertext
  3390. abcabcabc
  3391. \= Expect no match
  3392. xyz
  3393. /(?=abc){0}xyz/
  3394. xyz
  3395. /(?=abc){1}xyz/
  3396. \= Expect no match
  3397. xyz
  3398. /(?=(a))?./
  3399. ab
  3400. bc
  3401. /(?=(a))??./
  3402. ab
  3403. bc
  3404. /^(?=(?1))?[az]([abc])d/
  3405. abd
  3406. zcdxx
  3407. /^(?!a){0}\w+/
  3408. aaaaa
  3409. /(?<=(abc))?xyz/
  3410. abcxyz
  3411. pqrxyz
  3412. /^[\g<a>]+/
  3413. ggg<<<aaa>>>
  3414. \= Expect no match
  3415. \\ga
  3416. /^[\ga]+/
  3417. gggagagaxyz
  3418. /^[:a[:digit:]]+/
  3419. aaaa444:::Z
  3420. /^[:a[:digit:]:b]+/
  3421. aaaa444:::bbbZ
  3422. /[:a]xxx[b:]/
  3423. :xxx:
  3424. /(?<=a{2})b/i
  3425. xaabc
  3426. \= Expect no match
  3427. xabc
  3428. /(?<!a{2})b/i
  3429. xabc
  3430. \= Expect no match
  3431. xaabc
  3432. /(?<=a\h)c/
  3433. xa c
  3434. /(?<=[^a]{2})b/
  3435. axxbc
  3436. aAAbc
  3437. \= Expect no match
  3438. xaabc
  3439. /(?<=[^a]{2})b/i
  3440. axxbc
  3441. \= Expect no match
  3442. aAAbc
  3443. xaabc
  3444. /(?<=a\H)c/
  3445. abc
  3446. /(?<=a\V)c/
  3447. abc
  3448. /(?<=a\v)c/
  3449. a\nc
  3450. /(?(?=c)c|d)++Y/
  3451. XcccddYX
  3452. /(?(?=c)c|d)*+Y/
  3453. XcccddYX
  3454. /^(a{2,3}){2,}+a/
  3455. aaaaaaa
  3456. \= Expect no match
  3457. aaaaaa
  3458. aaaaaaaaa
  3459. /^(a{2,3})++a/
  3460. \= Expect no match
  3461. aaaaaa
  3462. /^(a{2,3})*+a/
  3463. \= Expect no match
  3464. aaaaaa
  3465. /\H\h\V\v/
  3466. X X\x0a
  3467. X\x09X\x0b
  3468. \= Expect no match
  3469. \xa0 X\x0a
  3470. /\H*\h+\V?\v{3,4}/
  3471. \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
  3472. \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
  3473. \x09\x20\xa0\x0a\x0b\x0c
  3474. \= Expect no match
  3475. \x09\x20\xa0\x0a\x0b
  3476. /\H{3,4}/
  3477. XY ABCDE
  3478. XY PQR ST
  3479. /.\h{3,4}./
  3480. XY AB PQRS
  3481. /\h*X\h?\H+Y\H?Z/
  3482. >XNNNYZ
  3483. > X NYQZ
  3484. \= Expect no match
  3485. >XYZ
  3486. > X NY Z
  3487. /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
  3488. >XY\x0aZ\x0aA\x0bNN\x0c
  3489. >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
  3490. /(foo)\Kbar/
  3491. foobar
  3492. /(foo)(\Kbar|baz)/
  3493. foobar
  3494. foobaz
  3495. /(foo\Kbar)baz/
  3496. foobarbaz
  3497. /abc\K|def\K/g,aftertext
  3498. Xabcdefghi
  3499. /ab\Kc|de\Kf/g,aftertext
  3500. Xabcdefghi
  3501. /(?=C)/g,aftertext
  3502. ABCDECBA
  3503. /^abc\K/aftertext
  3504. abcdef
  3505. \= Expect no match
  3506. defabcxyz
  3507. /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/
  3508. ababababbbabZXXXX
  3509. /(?<A>tom|bon)-\g{A}/
  3510. tom-tom
  3511. bon-bon
  3512. /(^(a|b\g{-1}))/
  3513. \= Expect no match
  3514. bacxxx
  3515. /(?|(abc)|(xyz))\1/
  3516. abcabc
  3517. xyzxyz
  3518. \= Expect no match
  3519. abcxyz
  3520. xyzabc
  3521. /(?|(abc)|(xyz))(?1)/
  3522. abcabc
  3523. xyzabc
  3524. \= Expect no match
  3525. xyzxyz
  3526. /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
  3527. XYabcdY
  3528. /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
  3529. XYabcdY
  3530. /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
  3531. XYabcdY
  3532. /(?'abc'\w+):\k<abc>{2}/
  3533. a:aaxyz
  3534. ab:ababxyz
  3535. \= Expect no match
  3536. a:axyz
  3537. ab:abxyz
  3538. /(?'abc'\w+):\g{abc}{2}/
  3539. a:aaxyz
  3540. ab:ababxyz
  3541. \= Expect no match
  3542. a:axyz
  3543. ab:abxyz
  3544. /^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
  3545. abd
  3546. ce
  3547. /^(a.)\g-1Z/
  3548. aXaXZ
  3549. /^(a.)\g{-1}Z/
  3550. aXaXZ
  3551. /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
  3552. abcd
  3553. /(?<all>(?:(?:a(?&all))|(b))(c?))/
  3554. aabc
  3555. /(a(b)|(c))(?1)/
  3556. abc
  3557. cab
  3558. /(?1)(a(b)|(c))/
  3559. abc
  3560. cab
  3561. /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
  3562. (?(DEFINE)
  3563. (?<NAME_PAT>[a-z]+)
  3564. (?<ADDRESS_PAT>\d+)
  3565. )/x
  3566. metcalfe 33
  3567. /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  3568. 1.2.3.4
  3569. 131.111.10.206
  3570. 10.0.0.0
  3571. \= Expect no match
  3572. 10.6
  3573. 455.3.4.5
  3574. /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  3575. 1.2.3.4
  3576. 131.111.10.206
  3577. 10.0.0.0
  3578. \= Expect no match
  3579. 10.6
  3580. 455.3.4.5
  3581. /^(\w++|\s++)*$/
  3582. now is the time for all good men to come to the aid of the party
  3583. \= Expect no match
  3584. this is not a line with only words and spaces!
  3585. /(\d++)(\w)/
  3586. 12345a
  3587. \= Expect no match
  3588. 12345+
  3589. /a++b/
  3590. aaab
  3591. /(a++b)/
  3592. aaab
  3593. /(a++)b/
  3594. aaab
  3595. /([^()]++|\([^()]*\))+/
  3596. ((abc(ade)ufh()()x
  3597. /\(([^()]++|\([^()]+\))+\)/
  3598. (abc)
  3599. (abc(def)xyz)
  3600. \= Expect no match
  3601. ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  3602. /^([^()]|\((?1)*\))*$/
  3603. abc
  3604. a(b)c
  3605. a(b(c))d
  3606. \= Expect no match)
  3607. a(b(c)d
  3608. /^>abc>([^()]|\((?1)*\))*<xyz<$/
  3609. >abc>123<xyz<
  3610. >abc>1(2)3<xyz<
  3611. >abc>(1(2)3)<xyz<
  3612. /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
  3613. 1221
  3614. Satanoscillatemymetallicsonatas
  3615. AmanaplanacanalPanama
  3616. AblewasIereIsawElba
  3617. \= Expect no match
  3618. Thequickbrownfox
  3619. /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
  3620. 12
  3621. (((2+2)*-3)-7)
  3622. -12
  3623. \= Expect no match
  3624. ((2+2)*-3)-7)
  3625. /^(x(y|(?1){2})z)/
  3626. xyz
  3627. xxyzxyzz
  3628. \= Expect no match
  3629. xxyzz
  3630. xxyzxyzxyzz
  3631. /((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
  3632. <>
  3633. <abcd>
  3634. <abc <123> hij>
  3635. <abc <def> hij>
  3636. <abc<>def>
  3637. <abc<>
  3638. \= Expect no match
  3639. <abc
  3640. /^a+(*FAIL)/
  3641. \= Expect no match
  3642. aaaaaa
  3643. /a+b?c+(*FAIL)/
  3644. \= Expect no match
  3645. aaabccc
  3646. /a+b?(*PRUNE)c+(*FAIL)/
  3647. \= Expect no match
  3648. aaabccc
  3649. /a+b?(*COMMIT)c+(*FAIL)/
  3650. \= Expect no match
  3651. aaabccc
  3652. /a+b?(*SKIP)c+(*FAIL)/
  3653. \= Expect no match
  3654. aaabcccaaabccc
  3655. /^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  3656. aaaxxxxxx
  3657. aaa++++++
  3658. bbbxxxxx
  3659. bbb+++++
  3660. cccxxxx
  3661. ccc++++
  3662. dddddddd
  3663. /^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  3664. aaaxxxxxx
  3665. aaa++++++
  3666. bbbxxxxx
  3667. bbb+++++
  3668. cccxxxx
  3669. ccc++++
  3670. dddddddd
  3671. /a+b?(*THEN)c+(*FAIL)/
  3672. \= Expect no match
  3673. aaabccc
  3674. /(A (A|B(*ACCEPT)|C) D)(E)/x
  3675. AB
  3676. ABX
  3677. AADE
  3678. ACDE
  3679. \= Expect no match
  3680. AD
  3681. /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  3682. 1221
  3683. Satan, oscillate my metallic sonatas!
  3684. A man, a plan, a canal: Panama!
  3685. Able was I ere I saw Elba.
  3686. \= Expect no match
  3687. The quick brown fox
  3688. /^((.)(?1)\2|.)$/
  3689. a
  3690. aba
  3691. aabaa
  3692. abcdcba
  3693. pqaabaaqp
  3694. ablewasiereisawelba
  3695. \= Expect no match
  3696. rhubarb
  3697. the quick brown fox
  3698. /(a)(?<=b(?1))/
  3699. baz
  3700. \= Expect no match
  3701. caz
  3702. /(?<=b(?1))(a)/
  3703. zbaaz
  3704. \= Expect no match
  3705. aaa
  3706. /(?<X>a)(?<=b(?&X))/
  3707. baz
  3708. /^(?|(abc)|(def))\1/
  3709. abcabc
  3710. defdef
  3711. \= Expect no match
  3712. abcdef
  3713. defabc
  3714. /^(?|(abc)|(def))(?1)/
  3715. abcabc
  3716. defabc
  3717. \= Expect no match
  3718. defdef
  3719. abcdef
  3720. /(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames
  3721. a\"aaaaa
  3722. b\"aaaaa
  3723. \= Expect no match
  3724. b\"11111
  3725. /(?:(?1)|B)(A(*F)|C)/
  3726. ABCD
  3727. CCD
  3728. \= Expect no match
  3729. CAD
  3730. /^(?:(?1)|B)(A(*F)|C)/
  3731. CCD
  3732. BCD
  3733. \= Expect no match
  3734. ABCD
  3735. CAD
  3736. BAD
  3737. /(?:(?1)|B)(A(*ACCEPT)XX|C)D/
  3738. AAD
  3739. ACD
  3740. BAD
  3741. BCD
  3742. BAX
  3743. \= Expect no match
  3744. ACX
  3745. ABC
  3746. /(?(DEFINE)(A))B(?1)C/
  3747. BAC
  3748. /(?(DEFINE)((A)\2))B(?1)C/
  3749. BAAC
  3750. /(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
  3751. (ab(cd)ef)
  3752. /^(?=a(*SKIP)b|ac)/
  3753. \= Expect no match
  3754. ac
  3755. /^(?=a(*PRUNE)b)/
  3756. ab
  3757. \= Expect no match
  3758. ac
  3759. /^(?=a(*ACCEPT)b)/
  3760. ac
  3761. /(?>a\Kb)/
  3762. ab
  3763. /((?>a\Kb))/
  3764. ab
  3765. /(a\Kb)/
  3766. ab
  3767. /^a\Kcz|ac/
  3768. ac
  3769. /(?>a\Kbz|ab)/
  3770. ab
  3771. /^(?&t)(?(DEFINE)(?<t>a\Kb))$/
  3772. ab
  3773. /^([^()]|\((?1)*\))*$/
  3774. a(b)c
  3775. a(b(c)d)e
  3776. /(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
  3777. 0
  3778. 00
  3779. 0000
  3780. /(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
  3781. 0
  3782. 00
  3783. 0000
  3784. # This one does fail, as expected, in Perl. It needs the complex item at the
  3785. # end of the pattern. A single letter instead of (B|D) makes it not fail, which
  3786. # I think is a Perl bug.
  3787. /A(*COMMIT)(B|D)/
  3788. \= Expect no match
  3789. ACABX
  3790. # Check the use of names for failure
  3791. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  3792. \= Expect no match
  3793. AC
  3794. CB
  3795. /(*MARK:A)(*SKIP:B)(C|X)/mark
  3796. C
  3797. \= Expect no match
  3798. D
  3799. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  3800. \= Expect no match
  3801. CB
  3802. /^(?:A(*THEN:A)B|C(*THEN:B)D)/mark
  3803. \= Expect no match
  3804. CB
  3805. /^(?>A(*THEN:A)B|C(*THEN:B)D)/mark
  3806. \= Expect no match
  3807. CB
  3808. # This should succeed, as the skip causes bump to offset 1 (the mark). Note
  3809. # that we have to have something complicated such as (B|Z) at the end because,
  3810. # for Perl, a simple character somehow causes an unwanted optimization to mess
  3811. # with the handling of backtracking verbs.
  3812. /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  3813. AAAC
  3814. # Test skipping over a non-matching mark.
  3815. /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/x,mark
  3816. AAAC
  3817. # Check shorthand for MARK.
  3818. /A(*:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  3819. AAAC
  3820. /(*:A)A+(*SKIP:A)(B|Z)/mark
  3821. \= Expect no match
  3822. AAAC
  3823. # This should succeed, as a non-existent skip name disables the skip.
  3824. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  3825. AAAC
  3826. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/x,mark
  3827. AAAC
  3828. # COMMIT at the start of a pattern should act like an anchor. Again, however,
  3829. # we need the complication for Perl.
  3830. /(*COMMIT)(A|P)(B|P)(C|P)/
  3831. ABCDEFG
  3832. \= Expect no match
  3833. DEFGABC
  3834. # COMMIT inside an atomic group can't stop backtracking over the group.
  3835. /(\w+)(?>b(*COMMIT))\w{2}/
  3836. abbb
  3837. /(\w+)b(*COMMIT)\w{2}/
  3838. \= Expect no match
  3839. abbb
  3840. # Check opening parens in comment when seeking forward reference.
  3841. /(?&t)(?#()(?(DEFINE)(?<t>a))/
  3842. bac
  3843. # COMMIT should override THEN.
  3844. /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
  3845. \= Expect no match
  3846. yes
  3847. /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
  3848. \= Expect no match
  3849. yes
  3850. /b?(*SKIP)c/
  3851. bc
  3852. abc
  3853. /(*SKIP)bc/
  3854. \= Expect no match
  3855. a
  3856. /(*SKIP)b/
  3857. \= Expect no match
  3858. a
  3859. /(?P<abn>(?P=abn)xxx|)+/
  3860. xxx
  3861. /(?i:([^b]))(?1)/
  3862. aa
  3863. aA
  3864. \= Expect no match
  3865. ab
  3866. aB
  3867. Ba
  3868. ba
  3869. /^(?&t)*+(?(DEFINE)(?<t>a))\w$/
  3870. aaaaaaX
  3871. \= Expect no match
  3872. aaaaaa
  3873. /^(?&t)*(?(DEFINE)(?<t>a))\w$/
  3874. aaaaaaX
  3875. aaaaaa
  3876. /^(a)*+(\w)/
  3877. aaaaX
  3878. YZ
  3879. \= Expect no match
  3880. aaaa
  3881. /^(?:a)*+(\w)/
  3882. aaaaX
  3883. YZ
  3884. \= Expect no match
  3885. aaaa
  3886. /^(a)++(\w)/
  3887. aaaaX
  3888. \= Expect no match
  3889. aaaa
  3890. YZ
  3891. /^(?:a)++(\w)/
  3892. aaaaX
  3893. \= Expect no match
  3894. aaaa
  3895. YZ
  3896. /^(a)?+(\w)/
  3897. aaaaX
  3898. YZ
  3899. /^(?:a)?+(\w)/
  3900. aaaaX
  3901. YZ
  3902. /^(a){2,}+(\w)/
  3903. aaaaX
  3904. \= Expect no match
  3905. aaa
  3906. YZ
  3907. /^(?:a){2,}+(\w)/
  3908. aaaaX
  3909. \= Expect no match
  3910. aaa
  3911. YZ
  3912. /(a|)*(?1)b/
  3913. b
  3914. ab
  3915. aab
  3916. /(a)++(?1)b/
  3917. \= Expect no match
  3918. ab
  3919. aab
  3920. /(a)*+(?1)b/
  3921. \= Expect no match
  3922. ab
  3923. aab
  3924. /(?1)(?:(b)){0}/
  3925. b
  3926. /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
  3927. foo(bar(baz)+baz(bop))
  3928. /(A (A|B(*ACCEPT)|C) D)(E)/x
  3929. AB
  3930. /\A.*?(a|bc)/
  3931. ba
  3932. /\A.*?(?:a|bc)++/
  3933. ba
  3934. /\A.*?(a|bc)++/
  3935. ba
  3936. /\A.*?(?:a|bc|d)/
  3937. ba
  3938. /(?:(b))++/
  3939. beetle
  3940. /(?(?=(a(*ACCEPT)z))a)/
  3941. a
  3942. /^(a)(?1)+ab/
  3943. aaaab
  3944. /^(a)(?1)++ab/
  3945. \= Expect no match
  3946. aaaab
  3947. /^(?=a(*:M))aZ/mark
  3948. aZbc
  3949. /^(?!(*:M)b)aZ/mark
  3950. aZbc
  3951. /(?(DEFINE)(a))?b(?1)/
  3952. backgammon
  3953. /^\N+/
  3954. abc\ndef
  3955. /^\N{1,}/
  3956. abc\ndef
  3957. /(?(R)a+|(?R)b)/
  3958. aaaabcde
  3959. /(?(R)a+|((?R))b)/
  3960. aaaabcde
  3961. /((?(R)a+|(?1)b))/
  3962. aaaabcde
  3963. /((?(R1)a+|(?1)b))/
  3964. aaaabcde
  3965. /((?(R)a|(?1)))*/
  3966. aaa
  3967. /((?(R)a|(?1)))+/
  3968. aaa
  3969. /a(*:any
  3970. name)/mark
  3971. abc
  3972. /(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
  3973. a
  3974. ba
  3975. bba
  3976. # Checking revised (*THEN) handling.
  3977. # Capture
  3978. /^.*? (a(*THEN)b) c/x
  3979. \= Expect no match
  3980. aabc
  3981. /^.*? (a(*THEN)b|(*F)) c/x
  3982. aabc
  3983. /^.*? ( (a(*THEN)b) | (*F) ) c/x
  3984. aabc
  3985. /^.*? ( (a(*THEN)b) ) c/x
  3986. \= Expect no match
  3987. aabc
  3988. # Non-capture
  3989. /^.*? (?:a(*THEN)b) c/x
  3990. \= Expect no match
  3991. aabc
  3992. /^.*? (?:a(*THEN)b|(*F)) c/x
  3993. aabc
  3994. /^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
  3995. aabc
  3996. /^.*? (?: (?:a(*THEN)b) ) c/x
  3997. \= Expect no match
  3998. aabc
  3999. # Atomic
  4000. /^.*? (?>a(*THEN)b) c/x
  4001. \= Expect no match
  4002. aabc
  4003. /^.*? (?>a(*THEN)b|(*F)) c/x
  4004. aabc
  4005. /^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
  4006. aabc
  4007. /^.*? (?> (?>a(*THEN)b) ) c/x
  4008. \= Expect no match
  4009. aabc
  4010. # Possessive capture
  4011. /^.*? (a(*THEN)b)++ c/x
  4012. \= Expect no match
  4013. aabc
  4014. /^.*? (a(*THEN)b|(*F))++ c/x
  4015. aabc
  4016. /^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
  4017. aabc
  4018. /^.*? ( (a(*THEN)b)++ )++ c/x
  4019. \= Expect no match
  4020. aabc
  4021. # Possessive non-capture
  4022. /^.*? (?:a(*THEN)b)++ c/x
  4023. \= Expect no match
  4024. aabc
  4025. /^.*? (?:a(*THEN)b|(*F))++ c/x
  4026. aabc
  4027. /^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
  4028. aabc
  4029. /^.*? (?: (?:a(*THEN)b)++ )++ c/x
  4030. \= Expect no match
  4031. aabc
  4032. # Condition assertion
  4033. /^(?(?=a(*THEN)b)ab|ac)/
  4034. ac
  4035. # Condition
  4036. /^.*?(?(?=a)a|b(*THEN)c)/
  4037. \= Expect no match
  4038. ba
  4039. /^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
  4040. ba
  4041. /^.*?(?(?=a)a(*THEN)b|c)/
  4042. \= Expect no match
  4043. ac
  4044. # Assertion
  4045. /^.*(?=a(*THEN)b)/
  4046. aabc
  4047. # --------------------------
  4048. /(?>a(*:m))/imsx,mark
  4049. a
  4050. /(?>(a)(*:m))/imsx,mark
  4051. a
  4052. /(?<=a(*ACCEPT)b)c/
  4053. xacd
  4054. /(?<=(a(*ACCEPT)b))c/
  4055. xacd
  4056. /(?<=(a(*COMMIT)b))c/
  4057. xabcd
  4058. \= Expect no match
  4059. xacd
  4060. /(?<!a(*FAIL)b)c/
  4061. xcd
  4062. acd
  4063. /(?<=a(*:N)b)c/mark
  4064. xabcd
  4065. /(?<=a(*PRUNE)b)c/
  4066. xabcd
  4067. /(?<=a(*SKIP)b)c/
  4068. xabcd
  4069. /(?<=a(*THEN)b)c/
  4070. xabcd
  4071. /(a)(?2){2}(.)/
  4072. abcd
  4073. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  4074. C
  4075. \= Expect no match
  4076. D
  4077. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  4078. C
  4079. \= Expect no match
  4080. D
  4081. /(*MARK:A)(*THEN:B)(C|X)/mark
  4082. C
  4083. \= Expect no match
  4084. D
  4085. /(*MARK:A)(*THEN:B)(C|X)/mark,no_start_optimize
  4086. C
  4087. \= Expect no match
  4088. D
  4089. /(*MARK:A)(*THEN:B)(C|X)/mark
  4090. C
  4091. \= Expect no match
  4092. D
  4093. # This should fail, as the skip causes a bump to offset 3 (the skip).
  4094. /A(*MARK:A)A+(*SKIP)(B|Z) | AC/x,mark
  4095. \= Expect no match
  4096. AAAC
  4097. # Same
  4098. /A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/x,mark
  4099. \= Expect no match
  4100. AAAC
  4101. /A(*:A)A+(*SKIP)(B|Z) | AC/x,mark
  4102. \= Expect no match
  4103. AAAC
  4104. # This should fail, as a null name is the same as no name.
  4105. /A(*MARK:A)A+(*SKIP:)(B|Z) | AC/x,mark
  4106. \= Expect no match
  4107. AAAC
  4108. # A check on what happens after hitting a mark and them bumping along to
  4109. # something that does not even start. Perl reports tags after the failures
  4110. # here, though it does not when the individual letters are made into something
  4111. # more complicated.
  4112. /A(*:A)B|XX(*:B)Y/mark
  4113. AABC
  4114. XXYZ
  4115. \= Expect no match
  4116. XAQQ
  4117. XAQQXZZ
  4118. AXQQQ
  4119. AXXQQQ
  4120. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  4121. AB
  4122. CD
  4123. \= Expect no match
  4124. AC
  4125. CB
  4126. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  4127. AB
  4128. CD
  4129. \= Expect no match
  4130. AC
  4131. CB
  4132. # An empty name does not pass back an empty string. It is the same as if no
  4133. # name were given.
  4134. /^(A(*PRUNE:)B|C(*PRUNE:B)D)/mark
  4135. AB
  4136. CD
  4137. # PRUNE goes to next bumpalong; COMMIT does not.
  4138. /A(*PRUNE:A)B/mark
  4139. ACAB
  4140. # Mark names can be duplicated.
  4141. /A(*:A)B|X(*:A)Y/mark
  4142. AABC
  4143. XXYZ
  4144. /b(*:m)f|a(*:n)w/mark
  4145. aw
  4146. \= Expect no match
  4147. abc
  4148. /b(*:m)f|aw/mark
  4149. abaw
  4150. \= Expect no match
  4151. abc
  4152. abax
  4153. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/x,mark
  4154. AAAC
  4155. /(?=a(*MARK:A)b)..x/mark
  4156. abxy
  4157. \= Expect no match
  4158. abpq
  4159. /(?=a(*MARK:A)b)..(*:Y)x/mark
  4160. abxy
  4161. \= Expect no match
  4162. abpq
  4163. /(?=a(*PRUNE:A)b)..x/mark
  4164. abxy
  4165. \= Expect no match
  4166. abpq
  4167. /(?=a(*PRUNE:A)b)..(*:Y)x/mark
  4168. abxy
  4169. \= Expect no match
  4170. abpq
  4171. /(?=a(*THEN:A)b)..x/mark
  4172. abxy
  4173. \= Expect no match
  4174. abpq
  4175. /(?=a(*THEN:A)b)..(*:Y)x/mark
  4176. abxy
  4177. \= Expect no match
  4178. abpq
  4179. /(another)?(\1?)test/
  4180. hello world test
  4181. /(another)?(\1+)test/
  4182. \= Expect no match
  4183. hello world test
  4184. /(a(*COMMIT)b){0}a(?1)|aac/
  4185. aac
  4186. /((?:a?)*)*c/
  4187. aac
  4188. /((?>a?)*)*c/
  4189. aac
  4190. /(?>.*?a)(?<=ba)/
  4191. aba
  4192. /(?:.*?a)(?<=ba)/
  4193. aba
  4194. /(?>.*?a)b/s
  4195. aab
  4196. /(?>.*?a)b/
  4197. aab
  4198. /(?>^a)b/s
  4199. \= Expect no match
  4200. aab
  4201. /(?>.*?)(?<=(abcd)|(wxyz))/
  4202. alphabetabcd
  4203. endingwxyz
  4204. /(?>.*)(?<=(abcd)|(wxyz))/
  4205. alphabetabcd
  4206. endingwxyz
  4207. /(?>.*)foo/
  4208. \= Expect no match
  4209. abcdfooxyz
  4210. /(?>.*?)foo/
  4211. abcdfooxyz
  4212. /(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/
  4213. ac
  4214. /(?:(a(*SKIP)b)){0}(?:(?1)|ac)/
  4215. ac
  4216. /(?<=(*SKIP)ac)a/
  4217. \= Expect no match
  4218. aa
  4219. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  4220. AAAC
  4221. /a(*SKIP:m)x|ac(*:n)(*SKIP:n)d|ac/mark
  4222. acacd
  4223. /A(*SKIP:m)x|A(*SKIP:n)x|AB/mark
  4224. AB
  4225. /((*SKIP:r)d){0}a(*SKIP:m)x|ac(*:n)|ac/mark
  4226. acacd
  4227. # Tests that try to figure out how Perl works. My hypothesis is that the first
  4228. # verb that is backtracked onto is the one that acts. This seems to be the case
  4229. # almost all the time, but there is one exception that is perhaps a bug.
  4230. # This matches "aaaac"; each PRUNE advances one character until the subject no
  4231. # longer starts with 5 'a's.
  4232. /aaaaa(*PRUNE)b|a+c/
  4233. aaaaaac
  4234. # Putting SKIP in front of PRUNE makes no difference, as it is never
  4235. # backtracked onto, whether or not it has a label.
  4236. /aaaaa(*SKIP)(*PRUNE)b|a+c/
  4237. aaaaaac
  4238. /aaaaa(*SKIP:N)(*PRUNE)b|a+c/
  4239. aaaaaac
  4240. /aaaa(*:N)a(*SKIP:N)(*PRUNE)b|a+c/
  4241. aaaaaac
  4242. # Putting THEN in front makes no difference.
  4243. /aaaaa(*THEN)(*PRUNE)b|a+c/
  4244. aaaaaac
  4245. # However, putting COMMIT in front of the prune changes it to "no match". I
  4246. # think this is inconsistent and possibly a bug. For the moment, running this
  4247. # test is moved out of the Perl-compatible file.
  4248. /aaaaa(*COMMIT)(*PRUNE)b|a+c/
  4249. # OK, lets play the same game again using SKIP instead of PRUNE.
  4250. # This matches "ac" because SKIP forces the next match to start on the
  4251. # sixth "a".
  4252. /aaaaa(*SKIP)b|a+c/
  4253. aaaaaac
  4254. # Putting PRUNE in front makes no difference.
  4255. /aaaaa(*PRUNE)(*SKIP)b|a+c/
  4256. aaaaaac
  4257. # Putting THEN in front makes no difference.
  4258. /aaaaa(*THEN)(*SKIP)b|a+c/
  4259. aaaaaac
  4260. # In this case, neither does COMMIT. This still matches "ac".
  4261. /aaaaa(*COMMIT)(*SKIP)b|a+c/
  4262. aaaaaac
  4263. # This gives "no match", as expected.
  4264. /aaaaa(*COMMIT)b|a+c/
  4265. \= Expect no match
  4266. aaaaaac
  4267. # ---- Tests using THEN ----
  4268. # This matches "aaaaaac", as expected.
  4269. /aaaaa(*THEN)b|a+c/
  4270. aaaaaac
  4271. # Putting SKIP in front makes no difference.
  4272. /aaaaa(*SKIP)(*THEN)b|a+c/
  4273. aaaaaac
  4274. # Putting PRUNE in front makes no difference.
  4275. /aaaaa(*PRUNE)(*THEN)b|a+c/
  4276. aaaaaac
  4277. # Putting COMMIT in front makes no difference.
  4278. /aaaaa(*COMMIT)(*THEN)b|a+c/
  4279. aaaaaac
  4280. # End of "priority" tests
  4281. /aaaaa(*:m)(*PRUNE:m)(*SKIP:m)m|a+/
  4282. aaaaaa
  4283. /aaaaa(*:m)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  4284. aaaaaa
  4285. /aaaaa(*:n)(*PRUNE:m)(*SKIP:m)m|a+/
  4286. aaaaaa
  4287. /aaaaa(*:n)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  4288. aaaaaa
  4289. /a(*MARK:A)aa(*PRUNE:A)a(*SKIP:A)b|a+c/
  4290. aaaac
  4291. /a(*MARK:A)aa(*MARK:A)a(*SKIP:A)b|a+c/
  4292. aaaac
  4293. /aaa(*PRUNE:A)a(*SKIP:A)b|a+c/
  4294. aaaac
  4295. /aaa(*MARK:A)a(*SKIP:A)b|a+c/
  4296. aaaac
  4297. /a(*:m)a(*COMMIT)(*SKIP:m)b|a+c/mark
  4298. aaaaaac
  4299. /.?(a|b(*THEN)c)/
  4300. ba
  4301. /(a(*COMMIT)b)c|abd/
  4302. abc
  4303. \= Expect no match
  4304. abd
  4305. /(?=a(*COMMIT)b)abc|abd/
  4306. abc
  4307. abd
  4308. /(?>a(*COMMIT)b)c|abd/
  4309. abc
  4310. abd
  4311. /a(?=b(*COMMIT)c)[^d]|abd/
  4312. abc
  4313. \= Expect no match
  4314. abd
  4315. /a(?=bc).|abd/
  4316. abd
  4317. abc
  4318. /a(?>b(*COMMIT)c)d|abd/
  4319. \= Expect no match
  4320. abceabd
  4321. /a(?>bc)d|abd/
  4322. abceabd
  4323. /(?>a(*COMMIT)b)c|abd/
  4324. abd
  4325. /(?>a(*COMMIT)c)d|abd/
  4326. \= Expect no match
  4327. abd
  4328. /((?=a(*COMMIT)b)ab|ac){0}(?:(?1)|a(c))/
  4329. ac
  4330. # These tests were formerly in test 2, but changes in PCRE and Perl have
  4331. # made them compatible.
  4332. /^(a)?(?(1)a|b)+$/
  4333. \= Expect no match
  4334. a
  4335. /A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  4336. \= Expect no match
  4337. AAAC
  4338. /^((abc|abcx)(*THEN)y|abcd)/
  4339. abcd
  4340. \= Expect no match
  4341. abcxy
  4342. /^((yes|no)(*THEN)(*F))?/
  4343. \= Expect no match
  4344. yes
  4345. /(A (.*) C? (*THEN) | A D) (*FAIL)/x
  4346. \= Expect no match
  4347. AbcdCBefgBhiBqz
  4348. /(A (.*) C? (*THEN) | A D) z/x
  4349. \= Expect no match
  4350. AbcdCBefgBhiBqz
  4351. /(A (.*) C? (*THEN) | A D) \s* (*FAIL)/x
  4352. \= Expect no match
  4353. AbcdCBefgBhiBqz
  4354. /(A (.*) C? (*THEN) | A D) \s* z/x
  4355. \= Expect no match
  4356. AbcdCBefgBhiBqz
  4357. /(A (.*) (?:C|) (*THEN) | A D) (*FAIL)/x
  4358. \= Expect no match
  4359. AbcdCBefgBhiBqz
  4360. /(A (.*) (?:C|) (*THEN) | A D) z/x
  4361. \= Expect no match
  4362. AbcdCBefgBhiBqz
  4363. /(A (.*) C{0,6} (*THEN) | A D) (*FAIL)/x
  4364. \= Expect no match
  4365. AbcdCBefgBhiBqz
  4366. /(A (.*) C{0,6} (*THEN) | A D) z/x
  4367. \= Expect no match
  4368. AbcdCBefgBhiBqz
  4369. /(A (.*) (CE){0,6} (*THEN) | A D) (*FAIL)/x
  4370. \= Expect no match
  4371. AbcdCEBefgBhiBqz
  4372. /(A (.*) (CE){0,6} (*THEN) | A D) z/x
  4373. \= Expect no match
  4374. AbcdCEBefgBhiBqz
  4375. /(A (.*) (CE*){0,6} (*THEN) | A D) (*FAIL)/x
  4376. \= Expect no match
  4377. AbcdCBefgBhiBqz
  4378. /(A (.*) (CE*){0,6} (*THEN) | A D) z/x
  4379. \= Expect no match
  4380. AbcdCBefgBhiBqz
  4381. /(?=a(*COMMIT)b|ac)ac|ac/
  4382. \= Expect no match
  4383. ac
  4384. /(?=a(*COMMIT)b|(ac)) ac | (a)c/x
  4385. \= Expect no match
  4386. ac
  4387. # ----
  4388. /(?(?!b(*THEN)a)bn|bnn)/
  4389. bnn
  4390. /(?!b(*SKIP)a)bn|bnn/
  4391. bnn
  4392. /(?(?!b(*SKIP)a)bn|bnn)/
  4393. bnn
  4394. /(?!b(*PRUNE)a)bn|bnn/
  4395. bnn
  4396. /(?(?!b(*PRUNE)a)bn|bnn)/
  4397. bnn
  4398. /(?!b(*COMMIT)a)bn|bnn/
  4399. bnn
  4400. /(?(?!b(*COMMIT)a)bn|bnn)/
  4401. bnn
  4402. /(?=b(*SKIP)a)bn|bnn/
  4403. \= Expect no match
  4404. bnn
  4405. /(?=b(*THEN)a)bn|bnn/
  4406. bnn
  4407. /^(?!a(*SKIP)b)/
  4408. ac
  4409. /^(?!a(*SKIP)b)../
  4410. acd
  4411. /(?!a(*SKIP)b)../
  4412. acd
  4413. /^(?(?!a(*SKIP)b))/
  4414. ac
  4415. /^(?!a(*PRUNE)b)../
  4416. acd
  4417. /(?!a(*PRUNE)b)../
  4418. acd
  4419. /(?!a(*COMMIT)b)ac|cd/
  4420. ac
  4421. /\A.*?(?:a|bc)/
  4422. ba
  4423. /^(A(*THEN)B|C(*THEN)D)/
  4424. CD
  4425. /(*:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4426. abc
  4427. /(*PRUNE:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4428. abc
  4429. /(*SKIP:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4430. abc
  4431. /(*THEN:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  4432. abc
  4433. /^\d*\w{4}/
  4434. 1234
  4435. \= Expect no match
  4436. 123
  4437. /^[^b]*\w{4}/
  4438. aaaa
  4439. \= Expect no match
  4440. aaa
  4441. /^[^b]*\w{4}/i
  4442. aaaa
  4443. \= Expect no match
  4444. aaa
  4445. /^a*\w{4}/
  4446. aaaa
  4447. \= Expect no match
  4448. aaa
  4449. /^a*\w{4}/i
  4450. aaaa
  4451. \= Expect no match
  4452. aaa
  4453. /(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  4454. foofoo
  4455. barbar
  4456. /(?<n>A)(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  4457. AfooA
  4458. AbarA
  4459. \= Expect no match
  4460. Afoofoo
  4461. Abarbar
  4462. /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
  4463. 1 IN SOA non-sp1 non-sp2(
  4464. /^ (?:(?<A>A)|(?'B'B)(?<A>A)) (?('A')x) (?(<B>)y)$/x,dupnames
  4465. Ax
  4466. BAxy
  4467. /^A\xZ/
  4468. A\0Z
  4469. /^A\o{123}B/
  4470. A\123B
  4471. / ^ a + + b $ /x
  4472. aaaab
  4473. / ^ a + #comment
  4474. + b $ /x
  4475. aaaab
  4476. / ^ a + #comment
  4477. #comment
  4478. + b $ /x
  4479. aaaab
  4480. / ^ (?> a + ) b $ /x
  4481. aaaab
  4482. / ^ ( a + ) + + \w $ /x
  4483. aaaab
  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. /(a\Kb)*/aftertext
  4493. ababc
  4494. /(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
  4495. \= Expect no match
  4496. acb
  4497. /\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++/
  4498. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4499. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++/
  4500. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4501. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")++\")++/
  4502. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4503. /\A([^\"1]++|[\"2]([^\"3]*+|[\"4][\"5])*+[\"6])++/
  4504. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  4505. /^\w+(?>\s*)(?<=\w)/
  4506. test test
  4507. /(?P<same>a)(?P<same>b)/g,dupnames
  4508. abbaba
  4509. /(?P<same>a)(?P<same>b)(?P=same)/g,dupnames
  4510. abbaba
  4511. /(?P=same)?(?P<same>a)(?P<same>b)/g,dupnames
  4512. abbaba
  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)){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. /(?<=X(?(DEFINE)(A)))X(*F)/
  5057. \= Expect no match
  5058. AXYZ
  5059. /(?<=X(?(DEFINE)(A)))./
  5060. AXYZ
  5061. /(?<=X(?(DEFINE)(.*))Y)./
  5062. AXYZ
  5063. /(?<=X(?(DEFINE)(Y))(?1))./
  5064. AXYZ
  5065. /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/
  5066. word
  5067. /a{1,2,3}b/
  5068. a{1,2,3}b
  5069. /\214748364/
  5070. >\x{8c}748364<
  5071. /a{65536/
  5072. >a{65536<
  5073. /a\K.(?0)*/
  5074. abac
  5075. /(a\K.(?1)*)/
  5076. abac
  5077. # --------------------------------------------------------------------------
  5078. # Perl-compatible tests of variable-length lookbehinds.
  5079. /(?<=ab?c).../g
  5080. abcdefgacxyz
  5081. /(?<=PQR|ab?c).../g
  5082. abcdefgacxyzPQR123
  5083. /(?<=ab?c|PQR).../g
  5084. abcdefgacxyzPQR123
  5085. /(?<=PQ|ab?c).../g
  5086. abcdefgacxyzPQR123
  5087. /(?<=ab?c|PQ).../g
  5088. abcdefgacxyzPQR123
  5089. /(?<=a(b?c|d?e?e)f)X./g
  5090. acfX1zzzaefX2zzzadeefX3zzzX4zzz
  5091. /(?<!a(b?c|d?e?e)f)X./g
  5092. acfX1zzzaefX2zzzadeefX3zzzX4zzz
  5093. /(?(?<=ab?c)d|e)/
  5094. abcdefg
  5095. acdefg
  5096. axdefg
  5097. /(?<=\d{2,3}|ABC)./
  5098. ABCD
  5099. /(?<=(\d{1,255}))X/
  5100. 1234X
  5101. /(?<=a(b?c){3}d)X/
  5102. ZXacbccdXYZ
  5103. /(?<=a(b?c){0}d)X/
  5104. ZXadXYZ
  5105. /(?<=a?(b?c){0}d)X./
  5106. ZXadXYZ
  5107. /(?<=\R)X/
  5108. \x{0a}X
  5109. a\x{0a}X
  5110. a\x{0d}\x{0a}X
  5111. # --------------------------------------------------------------------------
  5112. # Altered interpretation of {,n}
  5113. /a{,3}B/
  5114. XBBB
  5115. XaBBB
  5116. XaaBBB
  5117. XaaaBBB
  5118. XaaaaBBB
  5119. # But {,} remains not a qualifier
  5120. /a{,}B/
  5121. Xa{,}BBB
  5122. \= Expect no match
  5123. XBBB
  5124. XaBBB
  5125. # Checks for non-quantifiers after refactored code
  5126. /X{/
  5127. ZZX{}YY
  5128. /X{A/
  5129. ZZX{ABC}
  5130. /X{}/
  5131. ZZX{}YZ
  5132. /X{1234/
  5133. ZZX{123456
  5134. /X{12ABC}/
  5135. ZZX{12ABC}Y
  5136. /X{1,/
  5137. ZZX{1,...
  5138. /X{,9/
  5139. ZZX{,9}abc
  5140. /X{,9]/
  5141. ZZX{,9]..
  5142. # --------------------------------------------------------------------------
  5143. /(A)(?-1)(?+1)(B)/
  5144. xxAABBzz
  5145. /(A)(\g{ -2 }B)/
  5146. XAABX
  5147. /(A)((?-2)B)/
  5148. XAABX
  5149. /a\c\X/
  5150. --a\x1cX--
  5151. /(a)\g{ 1 }/
  5152. baab
  5153. /a{ 1,2 }/
  5154. Xaaaaa
  5155. /a{ 1 , 2 }/
  5156. Xaaaaa
  5157. /(?'name'ab)\k{ name }(?P=name)/
  5158. XabababX
  5159. /A{,}B/
  5160. A{,}B
  5161. /A{ , }B/
  5162. A{ , }B
  5163. /A{ ,3}/
  5164. AAAAAACC
  5165. /A{ 3, }/
  5166. BBAAAAAACC
  5167. # This pattern validates regular expression patterns. The original that I was
  5168. # sent was this:
  5169. # /^((?:(?:[^?+*{}()[\]\\|]+|\\.|\[(?:\^?\\.|\^[^\\]|[^\\^])(?:[^\]\\]+|\\.)*\]|\((?:\?[:=!]|\?<[=!]|\?>)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)$/
  5170. # This is not very readable, and also does not handle all features. I have done
  5171. # some work on it.
  5172. /^
  5173. (?<re>
  5174. # A regular expression is zero or more of these items.
  5175. (?:
  5176. # An item is one of these:
  5177. (?:
  5178. [^?+*{}()\[\]\\|]++| # Non-meta characters or unquoted .
  5179. \\.| # Quoted .
  5180. \[ # Class, which is [
  5181. (?: # Followed by
  5182. \^?\\.| # Optional ^ and any escaped character
  5183. \^[^\\]| # OR ^ and not escaped character
  5184. [^\\^] # OR neither ^ nor \
  5185. ) # Followed by
  5186. (?:[^\]\\]+|\\.)*+ # Zero or more (not ] or \) OR escaped dot
  5187. \]| # Class ends with ]
  5188. \( # Parenthesized group
  5189. (?: # Start with optional
  5190. \?[:=!]| # ? followed by : = !
  5191. \?<[=!]| # OR ?< followed by = or !
  5192. \?> # OR ?>
  5193. )?
  5194. (?&re)?? # Then a nested <re>
  5195. \)| # End parenthesized group
  5196. \(\? # Other parenthesized items
  5197. (?: # (? followed by
  5198. R| # R
  5199. [+-]?\d++ # Or optional +- and digits
  5200. )
  5201. \)| # End parens
  5202. \(\* # Verbs
  5203. (?:
  5204. COMMIT|
  5205. FAIL|
  5206. MARK:[^)]*|
  5207. (?:PRUNE|SKIP|THEN)(?::[^\)]*+)?
  5208. )
  5209. \)
  5210. ) # End list of items
  5211. # Followed by an optional quantifier
  5212. (?:
  5213. (?:
  5214. [?+*] # ?+*
  5215. | # OR
  5216. \{\d+ # { digits
  5217. (?:,\d*)? # optionally followed by ,digits
  5218. \} # then closing }
  5219. | # OR
  5220. \{,\d+} # {,digits}
  5221. )
  5222. [?+]? # optional ungreedy or possessive
  5223. )?
  5224. | # OR an "item" is a branch ending
  5225. \|
  5226. )* # Zero or more top-level items.
  5227. ) # End regex group.
  5228. $/x
  5229. [abcdef]
  5230. [abc\\]def]
  5231. a.b|abcd
  5232. ab()d
  5233. ab{1,3}d
  5234. ab{,3}d
  5235. ab(*FAIL)d(*COMMIT)(*SKIP)(*THEN:abc)
  5236. ab(*MARK:xyz)
  5237. (?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\\s])
  5238. abcd\\t\\n\\r\\f\\a\\e\\071\\x3b\\^\\\\\\?caxyz
  5239. a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz
  5240. \\G(?:(?=(\\1.|)(.))){1,13}?(?!.*\\2.*\\2)\\1\\K\\2
  5241. \= Expect no match
  5242. ab)d
  5243. ab(d
  5244. {4,5}
  5245. a[]b
  5246. (a)(?(1)a|b|c)
  5247. /^..A(*SKIP)B|C/
  5248. 12ADC
  5249. /(?<!a?)/
  5250. a
  5251. # End of testinput1