testoutput1 163 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506
  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. 0: the quick brown fox
  13. What do you know about the quick brown fox?
  14. 0: the quick brown fox
  15. \= Expect no match
  16. The quick brown FOX
  17. No match
  18. What do you know about THE QUICK BROWN FOX?
  19. No match
  20. /The quick brown fox/i
  21. the quick brown fox
  22. 0: the quick brown fox
  23. The quick brown FOX
  24. 0: The quick brown FOX
  25. What do you know about the quick brown fox?
  26. 0: the quick brown fox
  27. What do you know about THE QUICK BROWN FOX?
  28. 0: THE QUICK BROWN FOX
  29. /abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
  30. abcd\t\n\r\f\a\e9;\$\\?caxyz
  31. 0: abcd\x09\x0a\x0d\x0c\x07\x1b9;$\?caxyz
  32. /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
  33. abxyzpqrrrabbxyyyypqAzz
  34. 0: abxyzpqrrrabbxyyyypqAzz
  35. abxyzpqrrrabbxyyyypqAzz
  36. 0: abxyzpqrrrabbxyyyypqAzz
  37. aabxyzpqrrrabbxyyyypqAzz
  38. 0: aabxyzpqrrrabbxyyyypqAzz
  39. aaabxyzpqrrrabbxyyyypqAzz
  40. 0: aaabxyzpqrrrabbxyyyypqAzz
  41. aaaabxyzpqrrrabbxyyyypqAzz
  42. 0: aaaabxyzpqrrrabbxyyyypqAzz
  43. abcxyzpqrrrabbxyyyypqAzz
  44. 0: abcxyzpqrrrabbxyyyypqAzz
  45. aabcxyzpqrrrabbxyyyypqAzz
  46. 0: aabcxyzpqrrrabbxyyyypqAzz
  47. aaabcxyzpqrrrabbxyyyypAzz
  48. 0: aaabcxyzpqrrrabbxyyyypAzz
  49. aaabcxyzpqrrrabbxyyyypqAzz
  50. 0: aaabcxyzpqrrrabbxyyyypqAzz
  51. aaabcxyzpqrrrabbxyyyypqqAzz
  52. 0: aaabcxyzpqrrrabbxyyyypqqAzz
  53. aaabcxyzpqrrrabbxyyyypqqqAzz
  54. 0: aaabcxyzpqrrrabbxyyyypqqqAzz
  55. aaabcxyzpqrrrabbxyyyypqqqqAzz
  56. 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
  57. aaabcxyzpqrrrabbxyyyypqqqqqAzz
  58. 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
  59. aaabcxyzpqrrrabbxyyyypqqqqqqAzz
  60. 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
  61. aaaabcxyzpqrrrabbxyyyypqAzz
  62. 0: aaaabcxyzpqrrrabbxyyyypqAzz
  63. abxyzzpqrrrabbxyyyypqAzz
  64. 0: abxyzzpqrrrabbxyyyypqAzz
  65. aabxyzzzpqrrrabbxyyyypqAzz
  66. 0: aabxyzzzpqrrrabbxyyyypqAzz
  67. aaabxyzzzzpqrrrabbxyyyypqAzz
  68. 0: aaabxyzzzzpqrrrabbxyyyypqAzz
  69. aaaabxyzzzzpqrrrabbxyyyypqAzz
  70. 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
  71. abcxyzzpqrrrabbxyyyypqAzz
  72. 0: abcxyzzpqrrrabbxyyyypqAzz
  73. aabcxyzzzpqrrrabbxyyyypqAzz
  74. 0: aabcxyzzzpqrrrabbxyyyypqAzz
  75. aaabcxyzzzzpqrrrabbxyyyypqAzz
  76. 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
  77. aaaabcxyzzzzpqrrrabbxyyyypqAzz
  78. 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
  79. aaaabcxyzzzzpqrrrabbbxyyyypqAzz
  80. 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
  81. aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
  82. 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
  83. aaabcxyzpqrrrabbxyyyypABzz
  84. 0: aaabcxyzpqrrrabbxyyyypABzz
  85. aaabcxyzpqrrrabbxyyyypABBzz
  86. 0: aaabcxyzpqrrrabbxyyyypABBzz
  87. >>>aaabxyzpqrrrabbxyyyypqAzz
  88. 0: aaabxyzpqrrrabbxyyyypqAzz
  89. >aaaabxyzpqrrrabbxyyyypqAzz
  90. 0: aaaabxyzpqrrrabbxyyyypqAzz
  91. >>>>abcxyzpqrrrabbxyyyypqAzz
  92. 0: abcxyzpqrrrabbxyyyypqAzz
  93. \= Expect no match
  94. abxyzpqrrabbxyyyypqAzz
  95. No match
  96. abxyzpqrrrrabbxyyyypqAzz
  97. No match
  98. abxyzpqrrrabxyyyypqAzz
  99. No match
  100. aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
  101. No match
  102. aaaabcxyzzzzpqrrrabbbxyyypqAzz
  103. No match
  104. aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
  105. No match
  106. /^(abc){1,2}zz/
  107. abczz
  108. 0: abczz
  109. 1: abc
  110. abcabczz
  111. 0: abcabczz
  112. 1: abc
  113. \= Expect no match
  114. zz
  115. No match
  116. abcabcabczz
  117. No match
  118. >>abczz
  119. No match
  120. /^(b+?|a){1,2}?c/
  121. bc
  122. 0: bc
  123. 1: b
  124. bbc
  125. 0: bbc
  126. 1: b
  127. bbbc
  128. 0: bbbc
  129. 1: bb
  130. bac
  131. 0: bac
  132. 1: a
  133. bbac
  134. 0: bbac
  135. 1: a
  136. aac
  137. 0: aac
  138. 1: a
  139. abbbbbbbbbbbc
  140. 0: abbbbbbbbbbbc
  141. 1: bbbbbbbbbbb
  142. bbbbbbbbbbbac
  143. 0: bbbbbbbbbbbac
  144. 1: a
  145. \= Expect no match
  146. aaac
  147. No match
  148. abbbbbbbbbbbac
  149. No match
  150. /^(b+|a){1,2}c/
  151. bc
  152. 0: bc
  153. 1: b
  154. bbc
  155. 0: bbc
  156. 1: bb
  157. bbbc
  158. 0: bbbc
  159. 1: bbb
  160. bac
  161. 0: bac
  162. 1: a
  163. bbac
  164. 0: bbac
  165. 1: a
  166. aac
  167. 0: aac
  168. 1: a
  169. abbbbbbbbbbbc
  170. 0: abbbbbbbbbbbc
  171. 1: bbbbbbbbbbb
  172. bbbbbbbbbbbac
  173. 0: bbbbbbbbbbbac
  174. 1: a
  175. \= Expect no match
  176. aaac
  177. No match
  178. abbbbbbbbbbbac
  179. No match
  180. /^(ba|b*){1,2}?bc/
  181. babc
  182. 0: babc
  183. 1: ba
  184. bbabc
  185. 0: bbabc
  186. 1: ba
  187. bababc
  188. 0: bababc
  189. 1: ba
  190. \= Expect no match
  191. bababbc
  192. No match
  193. babababc
  194. No match
  195. /^\ca\cA\c[;\c:/
  196. \x01\x01\e;z
  197. 0: \x01\x01\x1b;z
  198. /^[ab\]cde]/
  199. athing
  200. 0: a
  201. bthing
  202. 0: b
  203. ]thing
  204. 0: ]
  205. cthing
  206. 0: c
  207. dthing
  208. 0: d
  209. ething
  210. 0: e
  211. \= Expect no match
  212. fthing
  213. No match
  214. [thing
  215. No match
  216. \\thing
  217. No match
  218. /^[]cde]/
  219. ]thing
  220. 0: ]
  221. cthing
  222. 0: c
  223. dthing
  224. 0: d
  225. ething
  226. 0: e
  227. \= Expect no match
  228. athing
  229. No match
  230. fthing
  231. No match
  232. /^[^ab\]cde]/
  233. fthing
  234. 0: f
  235. [thing
  236. 0: [
  237. \\thing
  238. 0: \
  239. \= Expect no match
  240. athing
  241. No match
  242. bthing
  243. No match
  244. ]thing
  245. No match
  246. cthing
  247. No match
  248. dthing
  249. No match
  250. ething
  251. No match
  252. /^[^]cde]/
  253. athing
  254. 0: a
  255. fthing
  256. 0: f
  257. \= Expect no match
  258. ]thing
  259. No match
  260. cthing
  261. No match
  262. dthing
  263. No match
  264. ething
  265. No match
  266. /^\�/
  267. 0: \x81
  268. /^ÿ/
  269. ÿ
  270. 0: \xff
  271. /^[0-9]+$/
  272. 0
  273. 0: 0
  274. 1
  275. 0: 1
  276. 2
  277. 0: 2
  278. 3
  279. 0: 3
  280. 4
  281. 0: 4
  282. 5
  283. 0: 5
  284. 6
  285. 0: 6
  286. 7
  287. 0: 7
  288. 8
  289. 0: 8
  290. 9
  291. 0: 9
  292. 10
  293. 0: 10
  294. 100
  295. 0: 100
  296. \= Expect no match
  297. abc
  298. No match
  299. /^.*nter/
  300. enter
  301. 0: enter
  302. inter
  303. 0: inter
  304. uponter
  305. 0: uponter
  306. /^xxx[0-9]+$/
  307. xxx0
  308. 0: xxx0
  309. xxx1234
  310. 0: xxx1234
  311. \= Expect no match
  312. xxx
  313. No match
  314. /^.+[0-9][0-9][0-9]$/
  315. x123
  316. 0: x123
  317. x1234
  318. 0: x1234
  319. xx123
  320. 0: xx123
  321. 123456
  322. 0: 123456
  323. \= Expect no match
  324. 123
  325. No match
  326. /^.+?[0-9][0-9][0-9]$/
  327. x123
  328. 0: x123
  329. x1234
  330. 0: x1234
  331. xx123
  332. 0: xx123
  333. 123456
  334. 0: 123456
  335. \= Expect no match
  336. 123
  337. No match
  338. /^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
  339. abc!pqr=apquxz.ixr.zzz.ac.uk
  340. 0: abc!pqr=apquxz.ixr.zzz.ac.uk
  341. 1: abc
  342. 2: pqr
  343. \= Expect no match
  344. !pqr=apquxz.ixr.zzz.ac.uk
  345. No match
  346. abc!=apquxz.ixr.zzz.ac.uk
  347. No match
  348. abc!pqr=apquxz:ixr.zzz.ac.uk
  349. No match
  350. abc!pqr=apquxz.ixr.zzz.ac.ukk
  351. No match
  352. /:/
  353. Well, we need a colon: somewhere
  354. 0: :
  355. \= Expect no match
  356. Fail without a colon
  357. No match
  358. /([\da-f:]+)$/i
  359. 0abc
  360. 0: 0abc
  361. 1: 0abc
  362. abc
  363. 0: abc
  364. 1: abc
  365. fed
  366. 0: fed
  367. 1: fed
  368. E
  369. 0: E
  370. 1: E
  371. ::
  372. 0: ::
  373. 1: ::
  374. 5f03:12C0::932e
  375. 0: 5f03:12C0::932e
  376. 1: 5f03:12C0::932e
  377. fed def
  378. 0: def
  379. 1: def
  380. Any old stuff
  381. 0: ff
  382. 1: ff
  383. \= Expect no match
  384. 0zzz
  385. No match
  386. gzzz
  387. No match
  388. fed\x20
  389. No match
  390. Any old rubbish
  391. No match
  392. /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
  393. .1.2.3
  394. 0: .1.2.3
  395. 1: 1
  396. 2: 2
  397. 3: 3
  398. A.12.123.0
  399. 0: A.12.123.0
  400. 1: 12
  401. 2: 123
  402. 3: 0
  403. \= Expect no match
  404. .1.2.3333
  405. No match
  406. 1.2.3
  407. No match
  408. 1234.2.3
  409. No match
  410. /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
  411. 1 IN SOA non-sp1 non-sp2(
  412. 0: 1 IN SOA non-sp1 non-sp2(
  413. 1: 1
  414. 2: non-sp1
  415. 3: non-sp2
  416. 1 IN SOA non-sp1 non-sp2 (
  417. 0: 1 IN SOA non-sp1 non-sp2 (
  418. 1: 1
  419. 2: non-sp1
  420. 3: non-sp2
  421. \= Expect no match
  422. 1IN SOA non-sp1 non-sp2(
  423. No match
  424. /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
  425. a.
  426. 0: a.
  427. Z.
  428. 0: Z.
  429. 2.
  430. 0: 2.
  431. ab-c.pq-r.
  432. 0: ab-c.pq-r.
  433. 1: .pq-r
  434. sxk.zzz.ac.uk.
  435. 0: sxk.zzz.ac.uk.
  436. 1: .uk
  437. x-.y-.
  438. 0: x-.y-.
  439. 1: .y-
  440. \= Expect no match
  441. -abc.peq.
  442. No match
  443. /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
  444. *.a
  445. 0: *.a
  446. *.b0-a
  447. 0: *.b0-a
  448. 1: 0-a
  449. *.c3-b.c
  450. 0: *.c3-b.c
  451. 1: 3-b
  452. 2: .c
  453. *.c-a.b-c
  454. 0: *.c-a.b-c
  455. 1: -a
  456. 2: .b-c
  457. 3: -c
  458. \= Expect no match
  459. *.0
  460. No match
  461. *.a-
  462. No match
  463. *.a-b.c-
  464. No match
  465. *.c-a.0-c
  466. No match
  467. /^(?=ab(de))(abd)(e)/
  468. abde
  469. 0: abde
  470. 1: de
  471. 2: abd
  472. 3: e
  473. /^(?!(ab)de|x)(abd)(f)/
  474. abdf
  475. 0: abdf
  476. 1: <unset>
  477. 2: abd
  478. 3: f
  479. /^(?=(ab(cd)))(ab)/
  480. abcd
  481. 0: ab
  482. 1: abcd
  483. 2: cd
  484. 3: ab
  485. /^[\da-f](\.[\da-f])*$/i
  486. a.b.c.d
  487. 0: a.b.c.d
  488. 1: .d
  489. A.B.C.D
  490. 0: A.B.C.D
  491. 1: .D
  492. a.b.c.1.2.3.C
  493. 0: a.b.c.1.2.3.C
  494. 1: .C
  495. /^\".*\"\s*(;.*)?$/
  496. \"1234\"
  497. 0: "1234"
  498. \"abcd\" ;
  499. 0: "abcd" ;
  500. 1: ;
  501. \"\" ; rhubarb
  502. 0: "" ; rhubarb
  503. 1: ; rhubarb
  504. \= Expect no match
  505. \"1234\" : things
  506. No match
  507. /^$/
  508. \
  509. 0:
  510. \= Expect no match
  511. A non-empty line
  512. No match
  513. / ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
  514. ab c
  515. 0: ab c
  516. \= Expect no match
  517. abc
  518. No match
  519. ab cde
  520. No match
  521. /(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
  522. ab c
  523. 0: ab c
  524. \= Expect no match
  525. abc
  526. No match
  527. ab cde
  528. No match
  529. /^ a\ b[c ]d $/x
  530. a bcd
  531. 0: a bcd
  532. a b d
  533. 0: a b d
  534. \= Expect no match
  535. abcd
  536. No match
  537. ab d
  538. No match
  539. /^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
  540. abcdefhijklm
  541. 0: abcdefhijklm
  542. 1: abc
  543. 2: bc
  544. 3: c
  545. 4: def
  546. 5: ef
  547. 6: f
  548. 7: hij
  549. 8: ij
  550. 9: j
  551. 10: klm
  552. 11: lm
  553. 12: m
  554. /^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
  555. abcdefhijklm
  556. 0: abcdefhijklm
  557. 1: bc
  558. 2: c
  559. 3: ef
  560. 4: f
  561. 5: ij
  562. 6: j
  563. 7: lm
  564. 8: m
  565. /^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
  566. a+ Z0+\x08\n\x1d\x12
  567. 0: a+ Z0+\x08\x0a\x1d\x12
  568. /^[.^$|()*+?{,}]+/
  569. .^\$(*+)|{?,?}
  570. 0: .^$(*+)|{?,?}
  571. /^a*\w/
  572. z
  573. 0: z
  574. az
  575. 0: az
  576. aaaz
  577. 0: aaaz
  578. a
  579. 0: a
  580. aa
  581. 0: aa
  582. aaaa
  583. 0: aaaa
  584. a+
  585. 0: a
  586. aa+
  587. 0: aa
  588. /^a*?\w/
  589. z
  590. 0: z
  591. az
  592. 0: a
  593. aaaz
  594. 0: a
  595. a
  596. 0: a
  597. aa
  598. 0: a
  599. aaaa
  600. 0: a
  601. a+
  602. 0: a
  603. aa+
  604. 0: a
  605. /^a+\w/
  606. az
  607. 0: az
  608. aaaz
  609. 0: aaaz
  610. aa
  611. 0: aa
  612. aaaa
  613. 0: aaaa
  614. aa+
  615. 0: aa
  616. /^a+?\w/
  617. az
  618. 0: az
  619. aaaz
  620. 0: aa
  621. aa
  622. 0: aa
  623. aaaa
  624. 0: aa
  625. aa+
  626. 0: aa
  627. /^\d{8}\w{2,}/
  628. 1234567890
  629. 0: 1234567890
  630. 12345678ab
  631. 0: 12345678ab
  632. 12345678__
  633. 0: 12345678__
  634. \= Expect no match
  635. 1234567
  636. No match
  637. /^[aeiou\d]{4,5}$/
  638. uoie
  639. 0: uoie
  640. 1234
  641. 0: 1234
  642. 12345
  643. 0: 12345
  644. aaaaa
  645. 0: aaaaa
  646. \= Expect no match
  647. 123456
  648. No match
  649. /^[aeiou\d]{4,5}?/
  650. uoie
  651. 0: uoie
  652. 1234
  653. 0: 1234
  654. 12345
  655. 0: 1234
  656. aaaaa
  657. 0: aaaa
  658. 123456
  659. 0: 1234
  660. /\A(abc|def)=(\1){2,3}\Z/
  661. abc=abcabc
  662. 0: abc=abcabc
  663. 1: abc
  664. 2: abc
  665. def=defdefdef
  666. 0: def=defdefdef
  667. 1: def
  668. 2: def
  669. \= Expect no match
  670. abc=defdef
  671. No match
  672. /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
  673. abcdefghijkcda2
  674. 0: abcdefghijkcda2
  675. 1: a
  676. 2: b
  677. 3: c
  678. 4: d
  679. 5: e
  680. 6: f
  681. 7: g
  682. 8: h
  683. 9: i
  684. 10: j
  685. 11: k
  686. 12: cd
  687. abcdefghijkkkkcda2
  688. 0: abcdefghijkkkkcda2
  689. 1: a
  690. 2: b
  691. 3: c
  692. 4: d
  693. 5: e
  694. 6: f
  695. 7: g
  696. 8: h
  697. 9: i
  698. 10: j
  699. 11: k
  700. 12: cd
  701. /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
  702. cataract cataract23
  703. 0: cataract cataract23
  704. 1: cataract
  705. 2: aract
  706. 3: ract
  707. 4:
  708. 5: 3
  709. catatonic catatonic23
  710. 0: catatonic catatonic23
  711. 1: catatonic
  712. 2: atonic
  713. 3: tonic
  714. 4:
  715. 5: 3
  716. caterpillar caterpillar23
  717. 0: caterpillar caterpillar23
  718. 1: caterpillar
  719. 2: erpillar
  720. 3: <unset>
  721. 4:
  722. 5: 3
  723. /^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]/
  724. From abcd Mon Sep 01 12:33:02 1997
  725. 0: From abcd Mon Sep 01 12:33
  726. 1: abcd
  727. /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
  728. From abcd Mon Sep 01 12:33:02 1997
  729. 0: From abcd Mon Sep 01 12:33
  730. 1: Sep
  731. From abcd Mon Sep 1 12:33:02 1997
  732. 0: From abcd Mon Sep 1 12:33
  733. 1: Sep
  734. \= Expect no match
  735. From abcd Sep 01 12:33:02 1997
  736. No match
  737. /^12.34/s
  738. 12\n34
  739. 0: 12\x0a34
  740. 12\r34
  741. 0: 12\x0d34
  742. /\w+(?=\t)/
  743. the quick brown\t fox
  744. 0: brown
  745. /foo(?!bar)(.*)/
  746. foobar is foolish see?
  747. 0: foolish see?
  748. 1: lish see?
  749. /(?:(?!foo)...|^.{0,2})bar(.*)/
  750. foobar crowbar etc
  751. 0: rowbar etc
  752. 1: etc
  753. barrel
  754. 0: barrel
  755. 1: rel
  756. 2barrel
  757. 0: 2barrel
  758. 1: rel
  759. A barrel
  760. 0: A barrel
  761. 1: rel
  762. /^(\D*)(?=\d)(?!123)/
  763. abc456
  764. 0: abc
  765. 1: abc
  766. \= Expect no match
  767. abc123
  768. No match
  769. /^1234(?# test newlines
  770. inside)/
  771. 1234
  772. 0: 1234
  773. /^1234 #comment in extended re
  774. /x
  775. 1234
  776. 0: 1234
  777. /#rhubarb
  778. abcd/x
  779. abcd
  780. 0: abcd
  781. /^abcd#rhubarb/x
  782. abcd
  783. 0: abcd
  784. /^(a)\1{2,3}(.)/
  785. aaab
  786. 0: aaab
  787. 1: a
  788. 2: b
  789. aaaab
  790. 0: aaaab
  791. 1: a
  792. 2: b
  793. aaaaab
  794. 0: aaaaa
  795. 1: a
  796. 2: a
  797. aaaaaab
  798. 0: aaaaa
  799. 1: a
  800. 2: a
  801. /(?!^)abc/
  802. the abc
  803. 0: abc
  804. \= Expect no match
  805. abc
  806. No match
  807. /(?=^)abc/
  808. abc
  809. 0: abc
  810. \= Expect no match
  811. the abc
  812. No match
  813. /^[ab]{1,3}(ab*|b)/
  814. aabbbbb
  815. 0: aabb
  816. 1: b
  817. /^[ab]{1,3}?(ab*|b)/
  818. aabbbbb
  819. 0: aabbbbb
  820. 1: abbbbb
  821. /^[ab]{1,3}?(ab*?|b)/
  822. aabbbbb
  823. 0: aa
  824. 1: a
  825. /^[ab]{1,3}(ab*?|b)/
  826. aabbbbb
  827. 0: aabb
  828. 1: b
  829. / (?: [\040\t] | \(
  830. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  831. \) )* # optional leading comment
  832. (?: (?:
  833. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  834. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  835. |
  836. " (?: # opening quote...
  837. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  838. | # or
  839. \\ [^\x80-\xff] # Escaped something (something != CR)
  840. )* " # closing quote
  841. ) # initial word
  842. (?: (?: [\040\t] | \(
  843. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  844. \) )* \. (?: [\040\t] | \(
  845. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  846. \) )* (?:
  847. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  848. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  849. |
  850. " (?: # opening quote...
  851. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  852. | # or
  853. \\ [^\x80-\xff] # Escaped something (something != CR)
  854. )* " # closing quote
  855. ) )* # further okay, if led by a period
  856. (?: [\040\t] | \(
  857. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  858. \) )* @ (?: [\040\t] | \(
  859. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  860. \) )* (?:
  861. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  862. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  863. | \[ # [
  864. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  865. \] # ]
  866. ) # initial subdomain
  867. (?: #
  868. (?: [\040\t] | \(
  869. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  870. \) )* \. # if led by a period...
  871. (?: [\040\t] | \(
  872. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  873. \) )* (?:
  874. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  875. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  876. | \[ # [
  877. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  878. \] # ]
  879. ) # ...further okay
  880. )*
  881. # address
  882. | # or
  883. (?:
  884. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  885. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  886. |
  887. " (?: # opening quote...
  888. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  889. | # or
  890. \\ [^\x80-\xff] # Escaped something (something != CR)
  891. )* " # closing quote
  892. ) # one word, optionally followed by....
  893. (?:
  894. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or...
  895. \(
  896. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  897. \) | # comments, or...
  898. " (?: # opening quote...
  899. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  900. | # or
  901. \\ [^\x80-\xff] # Escaped something (something != CR)
  902. )* " # closing quote
  903. # quoted strings
  904. )*
  905. < (?: [\040\t] | \(
  906. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  907. \) )* # leading <
  908. (?: @ (?: [\040\t] | \(
  909. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  910. \) )* (?:
  911. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  912. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  913. | \[ # [
  914. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  915. \] # ]
  916. ) # initial subdomain
  917. (?: #
  918. (?: [\040\t] | \(
  919. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  920. \) )* \. # if led by a period...
  921. (?: [\040\t] | \(
  922. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  923. \) )* (?:
  924. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  925. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  926. | \[ # [
  927. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  928. \] # ]
  929. ) # ...further okay
  930. )*
  931. (?: (?: [\040\t] | \(
  932. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  933. \) )* , (?: [\040\t] | \(
  934. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  935. \) )* @ (?: [\040\t] | \(
  936. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  937. \) )* (?:
  938. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  939. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  940. | \[ # [
  941. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  942. \] # ]
  943. ) # initial subdomain
  944. (?: #
  945. (?: [\040\t] | \(
  946. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  947. \) )* \. # if led by a period...
  948. (?: [\040\t] | \(
  949. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  950. \) )* (?:
  951. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  952. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  953. | \[ # [
  954. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  955. \] # ]
  956. ) # ...further okay
  957. )*
  958. )* # further okay, if led by comma
  959. : # closing colon
  960. (?: [\040\t] | \(
  961. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  962. \) )* )? # optional route
  963. (?:
  964. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  965. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  966. |
  967. " (?: # opening quote...
  968. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  969. | # or
  970. \\ [^\x80-\xff] # Escaped something (something != CR)
  971. )* " # closing quote
  972. ) # initial word
  973. (?: (?: [\040\t] | \(
  974. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  975. \) )* \. (?: [\040\t] | \(
  976. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  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. " (?: # opening quote...
  982. [^\\\x80-\xff\n\015"] # Anything except backslash and quote
  983. | # or
  984. \\ [^\x80-\xff] # Escaped something (something != CR)
  985. )* " # closing quote
  986. ) )* # further okay, if led by a period
  987. (?: [\040\t] | \(
  988. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  989. \) )* @ (?: [\040\t] | \(
  990. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  991. \) )* (?:
  992. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  993. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  994. | \[ # [
  995. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  996. \] # ]
  997. ) # initial subdomain
  998. (?: #
  999. (?: [\040\t] | \(
  1000. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  1001. \) )* \. # if led by a period...
  1002. (?: [\040\t] | \(
  1003. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  1004. \) )* (?:
  1005. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1006. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1007. | \[ # [
  1008. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1009. \] # ]
  1010. ) # ...further okay
  1011. )*
  1012. # address spec
  1013. (?: [\040\t] | \(
  1014. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  1015. \) )* > # trailing >
  1016. # name and address
  1017. ) (?: [\040\t] | \(
  1018. (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
  1019. \) )* # optional trailing comment
  1020. /x
  1021. Alan Other <user\@dom.ain>
  1022. 0: Alan Other <[email protected]>
  1023. <user\@dom.ain>
  1024. 0: [email protected]
  1025. user\@dom.ain
  1026. 0: [email protected]
  1027. \"A. Other\" <user.1234\@dom.ain> (a comment)
  1028. 0: "A. Other" <[email protected]> (a comment)
  1029. A. Other <user.1234\@dom.ain> (a comment)
  1030. 0: Other <[email protected]> (a comment)
  1031. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  1032. 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
  1033. A missing angle <user\@some.where
  1034. 0: [email protected]
  1035. \= Expect no match
  1036. The quick brown fox
  1037. No match
  1038. /[\040\t]* # Nab whitespace.
  1039. (?:
  1040. \( # (
  1041. [^\\\x80-\xff\n\015()] * # normal*
  1042. (?: # (
  1043. (?: \\ [^\x80-\xff] |
  1044. \( # (
  1045. [^\\\x80-\xff\n\015()] * # normal*
  1046. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1047. \) # )
  1048. ) # special
  1049. [^\\\x80-\xff\n\015()] * # normal*
  1050. )* # )*
  1051. \) # )
  1052. [\040\t]* )* # If comment found, allow more spaces.
  1053. # optional leading comment
  1054. (?:
  1055. (?:
  1056. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1057. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1058. # Atom
  1059. | # or
  1060. " # "
  1061. [^\\\x80-\xff\n\015"] * # normal
  1062. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1063. " # "
  1064. # Quoted string
  1065. )
  1066. [\040\t]* # Nab whitespace.
  1067. (?:
  1068. \( # (
  1069. [^\\\x80-\xff\n\015()] * # normal*
  1070. (?: # (
  1071. (?: \\ [^\x80-\xff] |
  1072. \( # (
  1073. [^\\\x80-\xff\n\015()] * # normal*
  1074. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1075. \) # )
  1076. ) # special
  1077. [^\\\x80-\xff\n\015()] * # normal*
  1078. )* # )*
  1079. \) # )
  1080. [\040\t]* )* # If comment found, allow more spaces.
  1081. (?:
  1082. \.
  1083. [\040\t]* # Nab whitespace.
  1084. (?:
  1085. \( # (
  1086. [^\\\x80-\xff\n\015()] * # normal*
  1087. (?: # (
  1088. (?: \\ [^\x80-\xff] |
  1089. \( # (
  1090. [^\\\x80-\xff\n\015()] * # normal*
  1091. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1092. \) # )
  1093. ) # special
  1094. [^\\\x80-\xff\n\015()] * # normal*
  1095. )* # )*
  1096. \) # )
  1097. [\040\t]* )* # If comment found, allow more spaces.
  1098. (?:
  1099. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1100. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1101. # Atom
  1102. | # or
  1103. " # "
  1104. [^\\\x80-\xff\n\015"] * # normal
  1105. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1106. " # "
  1107. # Quoted string
  1108. )
  1109. [\040\t]* # Nab whitespace.
  1110. (?:
  1111. \( # (
  1112. [^\\\x80-\xff\n\015()] * # normal*
  1113. (?: # (
  1114. (?: \\ [^\x80-\xff] |
  1115. \( # (
  1116. [^\\\x80-\xff\n\015()] * # normal*
  1117. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1118. \) # )
  1119. ) # special
  1120. [^\\\x80-\xff\n\015()] * # normal*
  1121. )* # )*
  1122. \) # )
  1123. [\040\t]* )* # If comment found, allow more spaces.
  1124. # additional words
  1125. )*
  1126. @
  1127. [\040\t]* # Nab whitespace.
  1128. (?:
  1129. \( # (
  1130. [^\\\x80-\xff\n\015()] * # normal*
  1131. (?: # (
  1132. (?: \\ [^\x80-\xff] |
  1133. \( # (
  1134. [^\\\x80-\xff\n\015()] * # normal*
  1135. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1136. \) # )
  1137. ) # special
  1138. [^\\\x80-\xff\n\015()] * # normal*
  1139. )* # )*
  1140. \) # )
  1141. [\040\t]* )* # If comment found, allow more spaces.
  1142. (?:
  1143. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1144. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1145. |
  1146. \[ # [
  1147. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1148. \] # ]
  1149. )
  1150. [\040\t]* # Nab whitespace.
  1151. (?:
  1152. \( # (
  1153. [^\\\x80-\xff\n\015()] * # normal*
  1154. (?: # (
  1155. (?: \\ [^\x80-\xff] |
  1156. \( # (
  1157. [^\\\x80-\xff\n\015()] * # normal*
  1158. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1159. \) # )
  1160. ) # special
  1161. [^\\\x80-\xff\n\015()] * # normal*
  1162. )* # )*
  1163. \) # )
  1164. [\040\t]* )* # If comment found, allow more spaces.
  1165. # optional trailing comments
  1166. (?:
  1167. \.
  1168. [\040\t]* # Nab whitespace.
  1169. (?:
  1170. \( # (
  1171. [^\\\x80-\xff\n\015()] * # normal*
  1172. (?: # (
  1173. (?: \\ [^\x80-\xff] |
  1174. \( # (
  1175. [^\\\x80-\xff\n\015()] * # normal*
  1176. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1177. \) # )
  1178. ) # special
  1179. [^\\\x80-\xff\n\015()] * # normal*
  1180. )* # )*
  1181. \) # )
  1182. [\040\t]* )* # If comment found, allow more spaces.
  1183. (?:
  1184. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1185. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1186. |
  1187. \[ # [
  1188. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1189. \] # ]
  1190. )
  1191. [\040\t]* # Nab whitespace.
  1192. (?:
  1193. \( # (
  1194. [^\\\x80-\xff\n\015()] * # normal*
  1195. (?: # (
  1196. (?: \\ [^\x80-\xff] |
  1197. \( # (
  1198. [^\\\x80-\xff\n\015()] * # normal*
  1199. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1200. \) # )
  1201. ) # special
  1202. [^\\\x80-\xff\n\015()] * # normal*
  1203. )* # )*
  1204. \) # )
  1205. [\040\t]* )* # If comment found, allow more spaces.
  1206. # optional trailing comments
  1207. )*
  1208. # address
  1209. | # or
  1210. (?:
  1211. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1212. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1213. # Atom
  1214. | # or
  1215. " # "
  1216. [^\\\x80-\xff\n\015"] * # normal
  1217. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1218. " # "
  1219. # Quoted string
  1220. )
  1221. # leading word
  1222. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces
  1223. (?:
  1224. (?:
  1225. \( # (
  1226. [^\\\x80-\xff\n\015()] * # normal*
  1227. (?: # (
  1228. (?: \\ [^\x80-\xff] |
  1229. \( # (
  1230. [^\\\x80-\xff\n\015()] * # normal*
  1231. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1232. \) # )
  1233. ) # special
  1234. [^\\\x80-\xff\n\015()] * # normal*
  1235. )* # )*
  1236. \) # )
  1237. |
  1238. " # "
  1239. [^\\\x80-\xff\n\015"] * # normal
  1240. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1241. " # "
  1242. ) # "special" comment or quoted string
  1243. [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal"
  1244. )*
  1245. <
  1246. [\040\t]* # Nab whitespace.
  1247. (?:
  1248. \( # (
  1249. [^\\\x80-\xff\n\015()] * # normal*
  1250. (?: # (
  1251. (?: \\ [^\x80-\xff] |
  1252. \( # (
  1253. [^\\\x80-\xff\n\015()] * # normal*
  1254. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1255. \) # )
  1256. ) # special
  1257. [^\\\x80-\xff\n\015()] * # normal*
  1258. )* # )*
  1259. \) # )
  1260. [\040\t]* )* # If comment found, allow more spaces.
  1261. # <
  1262. (?:
  1263. @
  1264. [\040\t]* # Nab whitespace.
  1265. (?:
  1266. \( # (
  1267. [^\\\x80-\xff\n\015()] * # normal*
  1268. (?: # (
  1269. (?: \\ [^\x80-\xff] |
  1270. \( # (
  1271. [^\\\x80-\xff\n\015()] * # normal*
  1272. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1273. \) # )
  1274. ) # special
  1275. [^\\\x80-\xff\n\015()] * # normal*
  1276. )* # )*
  1277. \) # )
  1278. [\040\t]* )* # If comment found, allow more spaces.
  1279. (?:
  1280. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1281. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1282. |
  1283. \[ # [
  1284. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1285. \] # ]
  1286. )
  1287. [\040\t]* # Nab whitespace.
  1288. (?:
  1289. \( # (
  1290. [^\\\x80-\xff\n\015()] * # normal*
  1291. (?: # (
  1292. (?: \\ [^\x80-\xff] |
  1293. \( # (
  1294. [^\\\x80-\xff\n\015()] * # normal*
  1295. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1296. \) # )
  1297. ) # special
  1298. [^\\\x80-\xff\n\015()] * # normal*
  1299. )* # )*
  1300. \) # )
  1301. [\040\t]* )* # If comment found, allow more spaces.
  1302. # optional trailing comments
  1303. (?:
  1304. \.
  1305. [\040\t]* # Nab whitespace.
  1306. (?:
  1307. \( # (
  1308. [^\\\x80-\xff\n\015()] * # normal*
  1309. (?: # (
  1310. (?: \\ [^\x80-\xff] |
  1311. \( # (
  1312. [^\\\x80-\xff\n\015()] * # normal*
  1313. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1314. \) # )
  1315. ) # special
  1316. [^\\\x80-\xff\n\015()] * # normal*
  1317. )* # )*
  1318. \) # )
  1319. [\040\t]* )* # If comment found, allow more spaces.
  1320. (?:
  1321. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1322. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1323. |
  1324. \[ # [
  1325. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1326. \] # ]
  1327. )
  1328. [\040\t]* # Nab whitespace.
  1329. (?:
  1330. \( # (
  1331. [^\\\x80-\xff\n\015()] * # normal*
  1332. (?: # (
  1333. (?: \\ [^\x80-\xff] |
  1334. \( # (
  1335. [^\\\x80-\xff\n\015()] * # normal*
  1336. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1337. \) # )
  1338. ) # special
  1339. [^\\\x80-\xff\n\015()] * # normal*
  1340. )* # )*
  1341. \) # )
  1342. [\040\t]* )* # If comment found, allow more spaces.
  1343. # optional trailing comments
  1344. )*
  1345. (?: ,
  1346. [\040\t]* # Nab whitespace.
  1347. (?:
  1348. \( # (
  1349. [^\\\x80-\xff\n\015()] * # normal*
  1350. (?: # (
  1351. (?: \\ [^\x80-\xff] |
  1352. \( # (
  1353. [^\\\x80-\xff\n\015()] * # normal*
  1354. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1355. \) # )
  1356. ) # special
  1357. [^\\\x80-\xff\n\015()] * # normal*
  1358. )* # )*
  1359. \) # )
  1360. [\040\t]* )* # If comment found, allow more spaces.
  1361. @
  1362. [\040\t]* # Nab whitespace.
  1363. (?:
  1364. \( # (
  1365. [^\\\x80-\xff\n\015()] * # normal*
  1366. (?: # (
  1367. (?: \\ [^\x80-\xff] |
  1368. \( # (
  1369. [^\\\x80-\xff\n\015()] * # normal*
  1370. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1371. \) # )
  1372. ) # special
  1373. [^\\\x80-\xff\n\015()] * # normal*
  1374. )* # )*
  1375. \) # )
  1376. [\040\t]* )* # If comment found, allow more spaces.
  1377. (?:
  1378. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1379. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1380. |
  1381. \[ # [
  1382. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1383. \] # ]
  1384. )
  1385. [\040\t]* # Nab whitespace.
  1386. (?:
  1387. \( # (
  1388. [^\\\x80-\xff\n\015()] * # normal*
  1389. (?: # (
  1390. (?: \\ [^\x80-\xff] |
  1391. \( # (
  1392. [^\\\x80-\xff\n\015()] * # normal*
  1393. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1394. \) # )
  1395. ) # special
  1396. [^\\\x80-\xff\n\015()] * # normal*
  1397. )* # )*
  1398. \) # )
  1399. [\040\t]* )* # If comment found, allow more spaces.
  1400. # optional trailing comments
  1401. (?:
  1402. \.
  1403. [\040\t]* # Nab whitespace.
  1404. (?:
  1405. \( # (
  1406. [^\\\x80-\xff\n\015()] * # normal*
  1407. (?: # (
  1408. (?: \\ [^\x80-\xff] |
  1409. \( # (
  1410. [^\\\x80-\xff\n\015()] * # normal*
  1411. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1412. \) # )
  1413. ) # special
  1414. [^\\\x80-\xff\n\015()] * # normal*
  1415. )* # )*
  1416. \) # )
  1417. [\040\t]* )* # If comment found, allow more spaces.
  1418. (?:
  1419. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1420. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1421. |
  1422. \[ # [
  1423. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1424. \] # ]
  1425. )
  1426. [\040\t]* # Nab whitespace.
  1427. (?:
  1428. \( # (
  1429. [^\\\x80-\xff\n\015()] * # normal*
  1430. (?: # (
  1431. (?: \\ [^\x80-\xff] |
  1432. \( # (
  1433. [^\\\x80-\xff\n\015()] * # normal*
  1434. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1435. \) # )
  1436. ) # special
  1437. [^\\\x80-\xff\n\015()] * # normal*
  1438. )* # )*
  1439. \) # )
  1440. [\040\t]* )* # If comment found, allow more spaces.
  1441. # optional trailing comments
  1442. )*
  1443. )* # additional domains
  1444. :
  1445. [\040\t]* # Nab whitespace.
  1446. (?:
  1447. \( # (
  1448. [^\\\x80-\xff\n\015()] * # normal*
  1449. (?: # (
  1450. (?: \\ [^\x80-\xff] |
  1451. \( # (
  1452. [^\\\x80-\xff\n\015()] * # normal*
  1453. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1454. \) # )
  1455. ) # special
  1456. [^\\\x80-\xff\n\015()] * # normal*
  1457. )* # )*
  1458. \) # )
  1459. [\040\t]* )* # If comment found, allow more spaces.
  1460. # optional trailing comments
  1461. )? # optional route
  1462. (?:
  1463. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1464. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1465. # Atom
  1466. | # or
  1467. " # "
  1468. [^\\\x80-\xff\n\015"] * # normal
  1469. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1470. " # "
  1471. # Quoted string
  1472. )
  1473. [\040\t]* # Nab whitespace.
  1474. (?:
  1475. \( # (
  1476. [^\\\x80-\xff\n\015()] * # normal*
  1477. (?: # (
  1478. (?: \\ [^\x80-\xff] |
  1479. \( # (
  1480. [^\\\x80-\xff\n\015()] * # normal*
  1481. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1482. \) # )
  1483. ) # special
  1484. [^\\\x80-\xff\n\015()] * # normal*
  1485. )* # )*
  1486. \) # )
  1487. [\040\t]* )* # If comment found, allow more spaces.
  1488. (?:
  1489. \.
  1490. [\040\t]* # Nab whitespace.
  1491. (?:
  1492. \( # (
  1493. [^\\\x80-\xff\n\015()] * # normal*
  1494. (?: # (
  1495. (?: \\ [^\x80-\xff] |
  1496. \( # (
  1497. [^\\\x80-\xff\n\015()] * # normal*
  1498. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1499. \) # )
  1500. ) # special
  1501. [^\\\x80-\xff\n\015()] * # normal*
  1502. )* # )*
  1503. \) # )
  1504. [\040\t]* )* # If comment found, allow more spaces.
  1505. (?:
  1506. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1507. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1508. # Atom
  1509. | # or
  1510. " # "
  1511. [^\\\x80-\xff\n\015"] * # normal
  1512. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
  1513. " # "
  1514. # Quoted string
  1515. )
  1516. [\040\t]* # Nab whitespace.
  1517. (?:
  1518. \( # (
  1519. [^\\\x80-\xff\n\015()] * # normal*
  1520. (?: # (
  1521. (?: \\ [^\x80-\xff] |
  1522. \( # (
  1523. [^\\\x80-\xff\n\015()] * # normal*
  1524. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1525. \) # )
  1526. ) # special
  1527. [^\\\x80-\xff\n\015()] * # normal*
  1528. )* # )*
  1529. \) # )
  1530. [\040\t]* )* # If comment found, allow more spaces.
  1531. # additional words
  1532. )*
  1533. @
  1534. [\040\t]* # Nab whitespace.
  1535. (?:
  1536. \( # (
  1537. [^\\\x80-\xff\n\015()] * # normal*
  1538. (?: # (
  1539. (?: \\ [^\x80-\xff] |
  1540. \( # (
  1541. [^\\\x80-\xff\n\015()] * # normal*
  1542. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1543. \) # )
  1544. ) # special
  1545. [^\\\x80-\xff\n\015()] * # normal*
  1546. )* # )*
  1547. \) # )
  1548. [\040\t]* )* # If comment found, allow more spaces.
  1549. (?:
  1550. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1551. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1552. |
  1553. \[ # [
  1554. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1555. \] # ]
  1556. )
  1557. [\040\t]* # Nab whitespace.
  1558. (?:
  1559. \( # (
  1560. [^\\\x80-\xff\n\015()] * # normal*
  1561. (?: # (
  1562. (?: \\ [^\x80-\xff] |
  1563. \( # (
  1564. [^\\\x80-\xff\n\015()] * # normal*
  1565. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1566. \) # )
  1567. ) # special
  1568. [^\\\x80-\xff\n\015()] * # normal*
  1569. )* # )*
  1570. \) # )
  1571. [\040\t]* )* # If comment found, allow more spaces.
  1572. # optional trailing comments
  1573. (?:
  1574. \.
  1575. [\040\t]* # Nab whitespace.
  1576. (?:
  1577. \( # (
  1578. [^\\\x80-\xff\n\015()] * # normal*
  1579. (?: # (
  1580. (?: \\ [^\x80-\xff] |
  1581. \( # (
  1582. [^\\\x80-\xff\n\015()] * # normal*
  1583. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1584. \) # )
  1585. ) # special
  1586. [^\\\x80-\xff\n\015()] * # normal*
  1587. )* # )*
  1588. \) # )
  1589. [\040\t]* )* # If comment found, allow more spaces.
  1590. (?:
  1591. [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
  1592. (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
  1593. |
  1594. \[ # [
  1595. (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
  1596. \] # ]
  1597. )
  1598. [\040\t]* # Nab whitespace.
  1599. (?:
  1600. \( # (
  1601. [^\\\x80-\xff\n\015()] * # normal*
  1602. (?: # (
  1603. (?: \\ [^\x80-\xff] |
  1604. \( # (
  1605. [^\\\x80-\xff\n\015()] * # normal*
  1606. (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
  1607. \) # )
  1608. ) # special
  1609. [^\\\x80-\xff\n\015()] * # normal*
  1610. )* # )*
  1611. \) # )
  1612. [\040\t]* )* # If comment found, allow more spaces.
  1613. # optional trailing comments
  1614. )*
  1615. # address spec
  1616. > # >
  1617. # name and address
  1618. )
  1619. /x
  1620. Alan Other <user\@dom.ain>
  1621. 0: Alan Other <[email protected]>
  1622. <user\@dom.ain>
  1623. 0: [email protected]
  1624. user\@dom.ain
  1625. 0: [email protected]
  1626. \"A. Other\" <user.1234\@dom.ain> (a comment)
  1627. 0: "A. Other" <[email protected]>
  1628. A. Other <user.1234\@dom.ain> (a comment)
  1629. 0: Other <[email protected]>
  1630. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  1631. 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
  1632. A missing angle <user\@some.where
  1633. 0: [email protected]
  1634. \= Expect no match
  1635. The quick brown fox
  1636. No match
  1637. /abc\0def\00pqr\000xyz\0000AB/
  1638. abc\0def\00pqr\000xyz\0000AB
  1639. 0: abc\x00def\x00pqr\x00xyz\x000AB
  1640. abc456 abc\0def\00pqr\000xyz\0000ABCDE
  1641. 0: abc\x00def\x00pqr\x00xyz\x000AB
  1642. /abc\x0def\x00pqr\x000xyz\x0000AB/
  1643. abc\x0def\x00pqr\x000xyz\x0000AB
  1644. 0: abc\x0def\x00pqr\x000xyz\x0000AB
  1645. abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
  1646. 0: abc\x0def\x00pqr\x000xyz\x0000AB
  1647. /^[\000-\037]/
  1648. \0A
  1649. 0: \x00
  1650. \01B
  1651. 0: \x01
  1652. \037C
  1653. 0: \x1f
  1654. /\0*/
  1655. \0\0\0\0
  1656. 0: \x00\x00\x00\x00
  1657. /A\x0{2,3}Z/
  1658. The A\x0\x0Z
  1659. 0: A\x00\x00Z
  1660. An A\0\x0\0Z
  1661. 0: A\x00\x00\x00Z
  1662. \= Expect no match
  1663. A\0Z
  1664. No match
  1665. A\0\x0\0\x0Z
  1666. No match
  1667. /^(cow|)\1(bell)/
  1668. cowcowbell
  1669. 0: cowcowbell
  1670. 1: cow
  1671. 2: bell
  1672. bell
  1673. 0: bell
  1674. 1:
  1675. 2: bell
  1676. \= Expect no match
  1677. cowbell
  1678. No match
  1679. /^\s/
  1680. \040abc
  1681. 0:
  1682. \x0cabc
  1683. 0: \x0c
  1684. \nabc
  1685. 0: \x0a
  1686. \rabc
  1687. 0: \x0d
  1688. \tabc
  1689. 0: \x09
  1690. \= Expect no match
  1691. abc
  1692. No match
  1693. /^a b
  1694. c/x
  1695. abc
  1696. 0: abc
  1697. /^(a|)\1*b/
  1698. ab
  1699. 0: ab
  1700. 1: a
  1701. aaaab
  1702. 0: aaaab
  1703. 1: a
  1704. b
  1705. 0: b
  1706. 1:
  1707. \= Expect no match
  1708. acb
  1709. No match
  1710. /^(a|)\1+b/
  1711. aab
  1712. 0: aab
  1713. 1: a
  1714. aaaab
  1715. 0: aaaab
  1716. 1: a
  1717. b
  1718. 0: b
  1719. 1:
  1720. \= Expect no match
  1721. ab
  1722. No match
  1723. /^(a|)\1?b/
  1724. ab
  1725. 0: ab
  1726. 1: a
  1727. aab
  1728. 0: aab
  1729. 1: a
  1730. b
  1731. 0: b
  1732. 1:
  1733. \= Expect no match
  1734. acb
  1735. No match
  1736. /^(a|)\1{2}b/
  1737. aaab
  1738. 0: aaab
  1739. 1: a
  1740. b
  1741. 0: b
  1742. 1:
  1743. \= Expect no match
  1744. ab
  1745. No match
  1746. aab
  1747. No match
  1748. aaaab
  1749. No match
  1750. /^(a|)\1{2,3}b/
  1751. aaab
  1752. 0: aaab
  1753. 1: a
  1754. aaaab
  1755. 0: aaaab
  1756. 1: a
  1757. b
  1758. 0: b
  1759. 1:
  1760. \= Expect no match
  1761. ab
  1762. No match
  1763. aab
  1764. No match
  1765. aaaaab
  1766. No match
  1767. /ab{1,3}bc/
  1768. abbbbc
  1769. 0: abbbbc
  1770. abbbc
  1771. 0: abbbc
  1772. abbc
  1773. 0: abbc
  1774. \= Expect no match
  1775. abc
  1776. No match
  1777. abbbbbc
  1778. No match
  1779. /([^.]*)\.([^:]*):[T ]+(.*)/
  1780. track1.title:TBlah blah blah
  1781. 0: track1.title:TBlah blah blah
  1782. 1: track1
  1783. 2: title
  1784. 3: Blah blah blah
  1785. /([^.]*)\.([^:]*):[T ]+(.*)/i
  1786. track1.title:TBlah blah blah
  1787. 0: track1.title:TBlah blah blah
  1788. 1: track1
  1789. 2: title
  1790. 3: Blah blah blah
  1791. /([^.]*)\.([^:]*):[t ]+(.*)/i
  1792. track1.title:TBlah blah blah
  1793. 0: track1.title:TBlah blah blah
  1794. 1: track1
  1795. 2: title
  1796. 3: Blah blah blah
  1797. /^[W-c]+$/
  1798. WXY_^abc
  1799. 0: WXY_^abc
  1800. \= Expect no match
  1801. wxy
  1802. No match
  1803. /^[W-c]+$/i
  1804. WXY_^abc
  1805. 0: WXY_^abc
  1806. wxy_^ABC
  1807. 0: wxy_^ABC
  1808. /^[\x3f-\x5F]+$/i
  1809. WXY_^abc
  1810. 0: WXY_^abc
  1811. wxy_^ABC
  1812. 0: wxy_^ABC
  1813. /^abc$/m
  1814. abc
  1815. 0: abc
  1816. qqq\nabc
  1817. 0: abc
  1818. abc\nzzz
  1819. 0: abc
  1820. qqq\nabc\nzzz
  1821. 0: abc
  1822. /^abc$/
  1823. abc
  1824. 0: abc
  1825. \= Expect no match
  1826. qqq\nabc
  1827. No match
  1828. abc\nzzz
  1829. No match
  1830. qqq\nabc\nzzz
  1831. No match
  1832. /\Aabc\Z/m
  1833. abc
  1834. 0: abc
  1835. abc\n
  1836. 0: abc
  1837. \= Expect no match
  1838. qqq\nabc
  1839. No match
  1840. abc\nzzz
  1841. No match
  1842. qqq\nabc\nzzz
  1843. No match
  1844. /\A(.)*\Z/s
  1845. abc\ndef
  1846. 0: abc\x0adef
  1847. 1: f
  1848. /\A(.)*\Z/m
  1849. \= Expect no match
  1850. abc\ndef
  1851. No match
  1852. /(?:b)|(?::+)/
  1853. b::c
  1854. 0: b
  1855. c::b
  1856. 0: ::
  1857. /[-az]+/
  1858. az-
  1859. 0: az-
  1860. \= Expect no match
  1861. b
  1862. No match
  1863. /[az-]+/
  1864. za-
  1865. 0: za-
  1866. \= Expect no match
  1867. b
  1868. No match
  1869. /[a\-z]+/
  1870. a-z
  1871. 0: a-z
  1872. \= Expect no match
  1873. b
  1874. No match
  1875. /[a-z]+/
  1876. abcdxyz
  1877. 0: abcdxyz
  1878. /[\d-]+/
  1879. 12-34
  1880. 0: 12-34
  1881. \= Expect no match
  1882. aaa
  1883. No match
  1884. /\x5c/
  1885. \\
  1886. 0: \
  1887. /\x20Z/
  1888. the Zoo
  1889. 0: Z
  1890. \= Expect no match
  1891. Zulu
  1892. No match
  1893. /(abc)\1/i
  1894. abcabc
  1895. 0: abcabc
  1896. 1: abc
  1897. ABCabc
  1898. 0: ABCabc
  1899. 1: ABC
  1900. abcABC
  1901. 0: abcABC
  1902. 1: abc
  1903. /abc$/
  1904. abc
  1905. 0: abc
  1906. abc\n
  1907. 0: abc
  1908. \= Expect no match
  1909. abc\ndef
  1910. No match
  1911. /(abc)\123/
  1912. abc\x53
  1913. 0: abcS
  1914. 1: abc
  1915. /(abc)\223/
  1916. abc\x93
  1917. 0: abc\x93
  1918. 1: abc
  1919. /(abc)\323/
  1920. abc\xd3
  1921. 0: abc\xd3
  1922. 1: abc
  1923. /(abc)\100/
  1924. abc\x40
  1925. 0: abc@
  1926. 1: abc
  1927. abc\100
  1928. 0: abc@
  1929. 1: abc
  1930. /(abc)\1000/
  1931. abc\x400
  1932. 0: abc@0
  1933. 1: abc
  1934. abc\x40\x30
  1935. 0: abc@0
  1936. 1: abc
  1937. abc\1000
  1938. 0: abc@0
  1939. 1: abc
  1940. abc\100\x30
  1941. 0: abc@0
  1942. 1: abc
  1943. abc\100\060
  1944. 0: abc@0
  1945. 1: abc
  1946. abc\100\60
  1947. 0: abc@0
  1948. 1: abc
  1949. /^(A)(B)(C)(D)(E)(F)(G)(H)(I)\8\9$/
  1950. ABCDEFGHIHI
  1951. 0: ABCDEFGHIHI
  1952. 1: A
  1953. 2: B
  1954. 3: C
  1955. 4: D
  1956. 5: E
  1957. 6: F
  1958. 7: G
  1959. 8: H
  1960. 9: I
  1961. /^[A\8B\9C]+$/
  1962. A8B9C
  1963. 0: A8B9C
  1964. \= Expect no match
  1965. A8B9C\x00
  1966. No match
  1967. /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
  1968. abcdefghijkllS
  1969. 0: abcdefghijkllS
  1970. 1: a
  1971. 2: b
  1972. 3: c
  1973. 4: d
  1974. 5: e
  1975. 6: f
  1976. 7: g
  1977. 8: h
  1978. 9: i
  1979. 10: j
  1980. 11: k
  1981. 12: l
  1982. /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
  1983. abcdefghijk\12S
  1984. 0: abcdefghijk\x0aS
  1985. 1: a
  1986. 2: b
  1987. 3: c
  1988. 4: d
  1989. 5: e
  1990. 6: f
  1991. 7: g
  1992. 8: h
  1993. 9: i
  1994. 10: j
  1995. 11: k
  1996. /a{0}bc/
  1997. bc
  1998. 0: bc
  1999. /(a|(bc)){0,0}?xyz/
  2000. xyz
  2001. 0: xyz
  2002. /abc[\10]de/
  2003. abc\010de
  2004. 0: abc\x08de
  2005. /abc[\1]de/
  2006. abc\1de
  2007. 0: abc\x01de
  2008. /(abc)[\1]de/
  2009. abc\1de
  2010. 0: abc\x01de
  2011. 1: abc
  2012. /(?s)a.b/
  2013. a\nb
  2014. 0: a\x0ab
  2015. /^([^a])([^\b])([^c]*)([^d]{3,4})/
  2016. baNOTccccd
  2017. 0: baNOTcccc
  2018. 1: b
  2019. 2: a
  2020. 3: NOT
  2021. 4: cccc
  2022. baNOTcccd
  2023. 0: baNOTccc
  2024. 1: b
  2025. 2: a
  2026. 3: NOT
  2027. 4: ccc
  2028. baNOTccd
  2029. 0: baNOTcc
  2030. 1: b
  2031. 2: a
  2032. 3: NO
  2033. 4: Tcc
  2034. bacccd
  2035. 0: baccc
  2036. 1: b
  2037. 2: a
  2038. 3:
  2039. 4: ccc
  2040. \= Expect no match
  2041. anything
  2042. No match
  2043. b\bc
  2044. No match
  2045. baccd
  2046. No match
  2047. /[^a]/
  2048. Abc
  2049. 0: A
  2050. /[^a]/i
  2051. Abc
  2052. 0: b
  2053. /[^a]+/
  2054. AAAaAbc
  2055. 0: AAA
  2056. /[^a]+/i
  2057. AAAaAbc
  2058. 0: bc
  2059. /[^a]+/
  2060. bbb\nccc
  2061. 0: bbb\x0accc
  2062. /[^k]$/
  2063. abc
  2064. 0: c
  2065. \= Expect no match
  2066. abk
  2067. No match
  2068. /[^k]{2,3}$/
  2069. abc
  2070. 0: abc
  2071. kbc
  2072. 0: bc
  2073. kabc
  2074. 0: abc
  2075. \= Expect no match
  2076. abk
  2077. No match
  2078. akb
  2079. No match
  2080. akk
  2081. No match
  2082. /^\d{8,}\@.+[^k]$/
  2083. 12345678\@a.b.c.d
  2084. 0: [email protected]
  2085. 123456789\@x.y.z
  2086. 0: [email protected]
  2087. \= Expect no match
  2088. 12345678\@x.y.uk
  2089. No match
  2090. 1234567\@a.b.c.d
  2091. No match
  2092. /(a)\1{8,}/
  2093. aaaaaaaaa
  2094. 0: aaaaaaaaa
  2095. 1: a
  2096. aaaaaaaaaa
  2097. 0: aaaaaaaaaa
  2098. 1: a
  2099. \= Expect no match
  2100. aaaaaaa
  2101. No match
  2102. /[^a]/
  2103. aaaabcd
  2104. 0: b
  2105. aaAabcd
  2106. 0: A
  2107. /[^a]/i
  2108. aaaabcd
  2109. 0: b
  2110. aaAabcd
  2111. 0: b
  2112. /[^az]/
  2113. aaaabcd
  2114. 0: b
  2115. aaAabcd
  2116. 0: A
  2117. /[^az]/i
  2118. aaaabcd
  2119. 0: b
  2120. aaAabcd
  2121. 0: b
  2122. /\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/
  2123. \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
  2124. 0: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
  2125. /P[^*]TAIRE[^*]{1,6}?LL/
  2126. xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
  2127. 0: PSTAIREISLL
  2128. /P[^*]TAIRE[^*]{1,}?LL/
  2129. xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
  2130. 0: PSTAIREISLL
  2131. /(\.\d\d[1-9]?)\d+/
  2132. 1.230003938
  2133. 0: .230003938
  2134. 1: .23
  2135. 1.875000282
  2136. 0: .875000282
  2137. 1: .875
  2138. 1.235
  2139. 0: .235
  2140. 1: .23
  2141. /(\.\d\d((?=0)|\d(?=\d)))/
  2142. 1.230003938
  2143. 0: .23
  2144. 1: .23
  2145. 2:
  2146. 1.875000282
  2147. 0: .875
  2148. 1: .875
  2149. 2: 5
  2150. \= Expect no match
  2151. 1.235
  2152. No match
  2153. /a(?)b/
  2154. ab
  2155. 0: ab
  2156. /\b(foo)\s+(\w+)/i
  2157. Food is on the foo table
  2158. 0: foo table
  2159. 1: foo
  2160. 2: table
  2161. /foo(.*)bar/
  2162. The food is under the bar in the barn.
  2163. 0: food is under the bar in the bar
  2164. 1: d is under the bar in the
  2165. /foo(.*?)bar/
  2166. The food is under the bar in the barn.
  2167. 0: food is under the bar
  2168. 1: d is under the
  2169. /(.*)(\d*)/
  2170. I have 2 numbers: 53147
  2171. 0: I have 2 numbers: 53147
  2172. 1: I have 2 numbers: 53147
  2173. 2:
  2174. /(.*)(\d+)/
  2175. I have 2 numbers: 53147
  2176. 0: I have 2 numbers: 53147
  2177. 1: I have 2 numbers: 5314
  2178. 2: 7
  2179. /(.*?)(\d*)/
  2180. I have 2 numbers: 53147
  2181. 0:
  2182. 1:
  2183. 2:
  2184. /(.*?)(\d+)/
  2185. I have 2 numbers: 53147
  2186. 0: I have 2
  2187. 1: I have
  2188. 2: 2
  2189. /(.*)(\d+)$/
  2190. I have 2 numbers: 53147
  2191. 0: I have 2 numbers: 53147
  2192. 1: I have 2 numbers: 5314
  2193. 2: 7
  2194. /(.*?)(\d+)$/
  2195. I have 2 numbers: 53147
  2196. 0: I have 2 numbers: 53147
  2197. 1: I have 2 numbers:
  2198. 2: 53147
  2199. /(.*)\b(\d+)$/
  2200. I have 2 numbers: 53147
  2201. 0: I have 2 numbers: 53147
  2202. 1: I have 2 numbers:
  2203. 2: 53147
  2204. /(.*\D)(\d+)$/
  2205. I have 2 numbers: 53147
  2206. 0: I have 2 numbers: 53147
  2207. 1: I have 2 numbers:
  2208. 2: 53147
  2209. /^\D*(?!123)/
  2210. ABC123
  2211. 0: AB
  2212. /^(\D*)(?=\d)(?!123)/
  2213. ABC445
  2214. 0: ABC
  2215. 1: ABC
  2216. \= Expect no match
  2217. ABC123
  2218. No match
  2219. /^[W-]46]/
  2220. W46]789
  2221. 0: W46]
  2222. -46]789
  2223. 0: -46]
  2224. \= Expect no match
  2225. Wall
  2226. No match
  2227. Zebra
  2228. No match
  2229. 42
  2230. No match
  2231. [abcd]
  2232. No match
  2233. ]abcd[
  2234. No match
  2235. /^[W-\]46]/
  2236. W46]789
  2237. 0: W
  2238. Wall
  2239. 0: W
  2240. Zebra
  2241. 0: Z
  2242. Xylophone
  2243. 0: X
  2244. 42
  2245. 0: 4
  2246. [abcd]
  2247. 0: [
  2248. ]abcd[
  2249. 0: ]
  2250. \\backslash
  2251. 0: \
  2252. \= Expect no match
  2253. -46]789
  2254. No match
  2255. well
  2256. No match
  2257. /\d\d\/\d\d\/\d\d\d\d/
  2258. 01/01/2000
  2259. 0: 01/01/2000
  2260. /word (?:[a-zA-Z0-9]+ ){0,10}otherword/
  2261. word cat dog elephant mussel cow horse canary baboon snake shark otherword
  2262. 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
  2263. \= Expect no match
  2264. word cat dog elephant mussel cow horse canary baboon snake shark
  2265. No match
  2266. /word (?:[a-zA-Z0-9]+ ){0,300}otherword/
  2267. \= Expect no match
  2268. 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
  2269. No match
  2270. /^(a){0,0}/
  2271. bcd
  2272. 0:
  2273. abc
  2274. 0:
  2275. aab
  2276. 0:
  2277. /^(a){0,1}/
  2278. bcd
  2279. 0:
  2280. abc
  2281. 0: a
  2282. 1: a
  2283. aab
  2284. 0: a
  2285. 1: a
  2286. /^(a){0,2}/
  2287. bcd
  2288. 0:
  2289. abc
  2290. 0: a
  2291. 1: a
  2292. aab
  2293. 0: aa
  2294. 1: a
  2295. /^(a){0,3}/
  2296. bcd
  2297. 0:
  2298. abc
  2299. 0: a
  2300. 1: a
  2301. aab
  2302. 0: aa
  2303. 1: a
  2304. aaa
  2305. 0: aaa
  2306. 1: a
  2307. /^(a){0,}/
  2308. bcd
  2309. 0:
  2310. abc
  2311. 0: a
  2312. 1: a
  2313. aab
  2314. 0: aa
  2315. 1: a
  2316. aaa
  2317. 0: aaa
  2318. 1: a
  2319. aaaaaaaa
  2320. 0: aaaaaaaa
  2321. 1: a
  2322. /^(a){1,1}/
  2323. abc
  2324. 0: a
  2325. 1: a
  2326. aab
  2327. 0: a
  2328. 1: a
  2329. \= Expect no match
  2330. bcd
  2331. No match
  2332. /^(a){1,2}/
  2333. abc
  2334. 0: a
  2335. 1: a
  2336. aab
  2337. 0: aa
  2338. 1: a
  2339. \= Expect no match
  2340. bcd
  2341. No match
  2342. /^(a){1,3}/
  2343. abc
  2344. 0: a
  2345. 1: a
  2346. aab
  2347. 0: aa
  2348. 1: a
  2349. aaa
  2350. 0: aaa
  2351. 1: a
  2352. \= Expect no match
  2353. bcd
  2354. No match
  2355. /^(a){1,}/
  2356. abc
  2357. 0: a
  2358. 1: a
  2359. aab
  2360. 0: aa
  2361. 1: a
  2362. aaa
  2363. 0: aaa
  2364. 1: a
  2365. aaaaaaaa
  2366. 0: aaaaaaaa
  2367. 1: a
  2368. \= Expect no match
  2369. bcd
  2370. No match
  2371. /.*\.gif/
  2372. borfle\nbib.gif\nno
  2373. 0: bib.gif
  2374. /.{0,}\.gif/
  2375. borfle\nbib.gif\nno
  2376. 0: bib.gif
  2377. /.*\.gif/m
  2378. borfle\nbib.gif\nno
  2379. 0: bib.gif
  2380. /.*\.gif/s
  2381. borfle\nbib.gif\nno
  2382. 0: borfle\x0abib.gif
  2383. /.*\.gif/ms
  2384. borfle\nbib.gif\nno
  2385. 0: borfle\x0abib.gif
  2386. /.*$/
  2387. borfle\nbib.gif\nno
  2388. 0: no
  2389. /.*$/m
  2390. borfle\nbib.gif\nno
  2391. 0: borfle
  2392. /.*$/s
  2393. borfle\nbib.gif\nno
  2394. 0: borfle\x0abib.gif\x0ano
  2395. /.*$/ms
  2396. borfle\nbib.gif\nno
  2397. 0: borfle\x0abib.gif\x0ano
  2398. /.*$/
  2399. borfle\nbib.gif\nno\n
  2400. 0: no
  2401. /.*$/m
  2402. borfle\nbib.gif\nno\n
  2403. 0: borfle
  2404. /.*$/s
  2405. borfle\nbib.gif\nno\n
  2406. 0: borfle\x0abib.gif\x0ano\x0a
  2407. /.*$/ms
  2408. borfle\nbib.gif\nno\n
  2409. 0: borfle\x0abib.gif\x0ano\x0a
  2410. /(.*X|^B)/
  2411. abcde\n1234Xyz
  2412. 0: 1234X
  2413. 1: 1234X
  2414. BarFoo
  2415. 0: B
  2416. 1: B
  2417. \= Expect no match
  2418. abcde\nBar
  2419. No match
  2420. /(.*X|^B)/m
  2421. abcde\n1234Xyz
  2422. 0: 1234X
  2423. 1: 1234X
  2424. BarFoo
  2425. 0: B
  2426. 1: B
  2427. abcde\nBar
  2428. 0: B
  2429. 1: B
  2430. /(.*X|^B)/s
  2431. abcde\n1234Xyz
  2432. 0: abcde\x0a1234X
  2433. 1: abcde\x0a1234X
  2434. BarFoo
  2435. 0: B
  2436. 1: B
  2437. \= Expect no match
  2438. abcde\nBar
  2439. No match
  2440. /(.*X|^B)/ms
  2441. abcde\n1234Xyz
  2442. 0: abcde\x0a1234X
  2443. 1: abcde\x0a1234X
  2444. BarFoo
  2445. 0: B
  2446. 1: B
  2447. abcde\nBar
  2448. 0: B
  2449. 1: B
  2450. /(?s)(.*X|^B)/
  2451. abcde\n1234Xyz
  2452. 0: abcde\x0a1234X
  2453. 1: abcde\x0a1234X
  2454. BarFoo
  2455. 0: B
  2456. 1: B
  2457. \= Expect no match
  2458. abcde\nBar
  2459. No match
  2460. /(?s:.*X|^B)/
  2461. abcde\n1234Xyz
  2462. 0: abcde\x0a1234X
  2463. BarFoo
  2464. 0: B
  2465. \= Expect no match
  2466. abcde\nBar
  2467. No match
  2468. /^.*B/
  2469. \= Expect no match
  2470. abc\nB
  2471. No match
  2472. /(?s)^.*B/
  2473. abc\nB
  2474. 0: abc\x0aB
  2475. /(?m)^.*B/
  2476. abc\nB
  2477. 0: B
  2478. /(?ms)^.*B/
  2479. abc\nB
  2480. 0: abc\x0aB
  2481. /(?ms)^B/
  2482. abc\nB
  2483. 0: B
  2484. /(?s)B$/
  2485. B\n
  2486. 0: B
  2487. /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
  2488. 123456654321
  2489. 0: 123456654321
  2490. /^\d\d\d\d\d\d\d\d\d\d\d\d/
  2491. 123456654321
  2492. 0: 123456654321
  2493. /^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
  2494. 123456654321
  2495. 0: 123456654321
  2496. /^[abc]{12}/
  2497. abcabcabcabc
  2498. 0: abcabcabcabc
  2499. /^[a-c]{12}/
  2500. abcabcabcabc
  2501. 0: abcabcabcabc
  2502. /^(a|b|c){12}/
  2503. abcabcabcabc
  2504. 0: abcabcabcabc
  2505. 1: c
  2506. /^[abcdefghijklmnopqrstuvwxy0123456789]/
  2507. n
  2508. 0: n
  2509. \= Expect no match
  2510. z
  2511. No match
  2512. /abcde{0,0}/
  2513. abcd
  2514. 0: abcd
  2515. \= Expect no match
  2516. abce
  2517. No match
  2518. /ab[cd]{0,0}e/
  2519. abe
  2520. 0: abe
  2521. \= Expect no match
  2522. abcde
  2523. No match
  2524. /ab(c){0,0}d/
  2525. abd
  2526. 0: abd
  2527. \= Expect no match
  2528. abcd
  2529. No match
  2530. /a(b*)/
  2531. a
  2532. 0: a
  2533. 1:
  2534. ab
  2535. 0: ab
  2536. 1: b
  2537. abbbb
  2538. 0: abbbb
  2539. 1: bbbb
  2540. \= Expect no match
  2541. bbbbb
  2542. No match
  2543. /ab\d{0}e/
  2544. abe
  2545. 0: abe
  2546. \= Expect no match
  2547. ab1e
  2548. No match
  2549. /"([^\\"]+|\\.)*"/
  2550. the \"quick\" brown fox
  2551. 0: "quick"
  2552. 1: quick
  2553. \"the \\\"quick\\\" brown fox\"
  2554. 0: "the \"quick\" brown fox"
  2555. 1: brown fox
  2556. /.*?/g,aftertext
  2557. abc
  2558. 0:
  2559. 0+ abc
  2560. 0: a
  2561. 0+ bc
  2562. 0:
  2563. 0+ bc
  2564. 0: b
  2565. 0+ c
  2566. 0:
  2567. 0+ c
  2568. 0: c
  2569. 0+
  2570. 0:
  2571. 0+
  2572. /\b/g,aftertext
  2573. abc
  2574. 0:
  2575. 0+ abc
  2576. 0:
  2577. 0+
  2578. /\b/g,aftertext
  2579. abc
  2580. 0:
  2581. 0+ abc
  2582. 0:
  2583. 0+
  2584. //g
  2585. abc
  2586. 0:
  2587. 0:
  2588. 0:
  2589. 0:
  2590. /<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
  2591. <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>
  2592. 0: <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>
  2593. 1: BGCOLOR='#DBE9E9'
  2594. 2: align=left valign=top
  2595. 3: 43.
  2596. 4: <a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)
  2597. 5:
  2598. 6:
  2599. 7: <unset>
  2600. 8: align=left valign=top
  2601. 9: Lega lstaff.com
  2602. 10: align=left valign=top
  2603. 11: CA - Statewide
  2604. /a[^a]b/
  2605. acb
  2606. 0: acb
  2607. a\nb
  2608. 0: a\x0ab
  2609. /a.b/
  2610. acb
  2611. 0: acb
  2612. \= Expect no match
  2613. a\nb
  2614. No match
  2615. /a[^a]b/s
  2616. acb
  2617. 0: acb
  2618. a\nb
  2619. 0: a\x0ab
  2620. /a.b/s
  2621. acb
  2622. 0: acb
  2623. a\nb
  2624. 0: a\x0ab
  2625. /^(b+?|a){1,2}?c/
  2626. bac
  2627. 0: bac
  2628. 1: a
  2629. bbac
  2630. 0: bbac
  2631. 1: a
  2632. bbbac
  2633. 0: bbbac
  2634. 1: a
  2635. bbbbac
  2636. 0: bbbbac
  2637. 1: a
  2638. bbbbbac
  2639. 0: bbbbbac
  2640. 1: a
  2641. /^(b+|a){1,2}?c/
  2642. bac
  2643. 0: bac
  2644. 1: a
  2645. bbac
  2646. 0: bbac
  2647. 1: a
  2648. bbbac
  2649. 0: bbbac
  2650. 1: a
  2651. bbbbac
  2652. 0: bbbbac
  2653. 1: a
  2654. bbbbbac
  2655. 0: bbbbbac
  2656. 1: a
  2657. /(?!\A)x/m
  2658. a\bx\n
  2659. 0: x
  2660. a\nx\n
  2661. 0: x
  2662. \= Expect no match
  2663. x\nb\n
  2664. No match
  2665. /(A|B)*?CD/
  2666. CD
  2667. 0: CD
  2668. /(A|B)*CD/
  2669. CD
  2670. 0: CD
  2671. /(AB)*?\1/
  2672. ABABAB
  2673. 0: ABAB
  2674. 1: AB
  2675. /(AB)*\1/
  2676. ABABAB
  2677. 0: ABABAB
  2678. 1: AB
  2679. /(?<!bar)foo/
  2680. foo
  2681. 0: foo
  2682. catfood
  2683. 0: foo
  2684. arfootle
  2685. 0: foo
  2686. rfoosh
  2687. 0: foo
  2688. \= Expect no match
  2689. barfoo
  2690. No match
  2691. towbarfoo
  2692. No match
  2693. /\w{3}(?<!bar)foo/
  2694. catfood
  2695. 0: catfoo
  2696. \= Expect no match
  2697. foo
  2698. No match
  2699. barfoo
  2700. No match
  2701. towbarfoo
  2702. No match
  2703. /(?<=(foo)a)bar/
  2704. fooabar
  2705. 0: bar
  2706. 1: foo
  2707. \= Expect no match
  2708. bar
  2709. No match
  2710. foobbar
  2711. No match
  2712. /\Aabc\z/m
  2713. abc
  2714. 0: abc
  2715. \= Expect no match
  2716. abc\n
  2717. No match
  2718. qqq\nabc
  2719. No match
  2720. abc\nzzz
  2721. No match
  2722. qqq\nabc\nzzz
  2723. No match
  2724. /(?>.*\/)foo/
  2725. /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
  2726. 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
  2727. \= Expect no match
  2728. /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
  2729. No match
  2730. /(?>(\.\d\d[1-9]?))\d+/
  2731. 1.230003938
  2732. 0: .230003938
  2733. 1: .23
  2734. 1.875000282
  2735. 0: .875000282
  2736. 1: .875
  2737. \= Expect no match
  2738. 1.235
  2739. No match
  2740. /^((?>\w+)|(?>\s+))*$/
  2741. now is the time for all good men to come to the aid of the party
  2742. 0: now is the time for all good men to come to the aid of the party
  2743. 1: party
  2744. \= Expect no match
  2745. this is not a line with only words and spaces!
  2746. No match
  2747. /(\d+)(\w)/
  2748. 12345a
  2749. 0: 12345a
  2750. 1: 12345
  2751. 2: a
  2752. 12345+
  2753. 0: 12345
  2754. 1: 1234
  2755. 2: 5
  2756. /((?>\d+))(\w)/
  2757. 12345a
  2758. 0: 12345a
  2759. 1: 12345
  2760. 2: a
  2761. \= Expect no match
  2762. 12345+
  2763. No match
  2764. /(?>a+)b/
  2765. aaab
  2766. 0: aaab
  2767. /((?>a+)b)/
  2768. aaab
  2769. 0: aaab
  2770. 1: aaab
  2771. /(?>(a+))b/
  2772. aaab
  2773. 0: aaab
  2774. 1: aaa
  2775. /(?>b)+/
  2776. aaabbbccc
  2777. 0: bbb
  2778. /(?>a+|b+|c+)*c/
  2779. aaabbbbccccd
  2780. 0: aaabbbbc
  2781. /((?>[^()]+)|\([^()]*\))+/
  2782. ((abc(ade)ufh()()x
  2783. 0: abc(ade)ufh()()x
  2784. 1: x
  2785. /\(((?>[^()]+)|\([^()]+\))+\)/
  2786. (abc)
  2787. 0: (abc)
  2788. 1: abc
  2789. (abc(def)xyz)
  2790. 0: (abc(def)xyz)
  2791. 1: xyz
  2792. \= Expect no match
  2793. ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  2794. No match
  2795. /a(?-i)b/i
  2796. ab
  2797. 0: ab
  2798. Ab
  2799. 0: Ab
  2800. \= Expect no match
  2801. aB
  2802. No match
  2803. AB
  2804. No match
  2805. /(a (?x)b c)d e/
  2806. a bcd e
  2807. 0: a bcd e
  2808. 1: a bc
  2809. \= Expect no match
  2810. a b cd e
  2811. No match
  2812. abcd e
  2813. No match
  2814. a bcde
  2815. No match
  2816. /(a b(?x)c d (?-x)e f)/
  2817. a bcde f
  2818. 0: a bcde f
  2819. 1: a bcde f
  2820. \= Expect no match
  2821. abcdef
  2822. No match
  2823. /(a(?i)b)c/
  2824. abc
  2825. 0: abc
  2826. 1: ab
  2827. aBc
  2828. 0: aBc
  2829. 1: aB
  2830. \= Expect no match
  2831. abC
  2832. No match
  2833. aBC
  2834. No match
  2835. Abc
  2836. No match
  2837. ABc
  2838. No match
  2839. ABC
  2840. No match
  2841. AbC
  2842. No match
  2843. /a(?i:b)c/
  2844. abc
  2845. 0: abc
  2846. aBc
  2847. 0: aBc
  2848. \= Expect no match
  2849. ABC
  2850. No match
  2851. abC
  2852. No match
  2853. aBC
  2854. No match
  2855. /a(?i:b)*c/
  2856. aBc
  2857. 0: aBc
  2858. aBBc
  2859. 0: aBBc
  2860. \= Expect no match
  2861. aBC
  2862. No match
  2863. aBBC
  2864. No match
  2865. /a(?=b(?i)c)\w\wd/
  2866. abcd
  2867. 0: abcd
  2868. abCd
  2869. 0: abCd
  2870. \= Expect no match
  2871. aBCd
  2872. No match
  2873. abcD
  2874. No match
  2875. /(?s-i:more.*than).*million/i
  2876. more than million
  2877. 0: more than million
  2878. more than MILLION
  2879. 0: more than MILLION
  2880. more \n than Million
  2881. 0: more \x0a than Million
  2882. \= Expect no match
  2883. MORE THAN MILLION
  2884. No match
  2885. more \n than \n million
  2886. No match
  2887. /(?:(?s-i)more.*than).*million/i
  2888. more than million
  2889. 0: more than million
  2890. more than MILLION
  2891. 0: more than MILLION
  2892. more \n than Million
  2893. 0: more \x0a than Million
  2894. \= Expect no match
  2895. MORE THAN MILLION
  2896. No match
  2897. more \n than \n million
  2898. No match
  2899. /(?>a(?i)b+)+c/
  2900. abc
  2901. 0: abc
  2902. aBbc
  2903. 0: aBbc
  2904. aBBc
  2905. 0: aBBc
  2906. \= Expect no match
  2907. Abc
  2908. No match
  2909. abAb
  2910. No match
  2911. abbC
  2912. No match
  2913. /(?=a(?i)b)\w\wc/
  2914. abc
  2915. 0: abc
  2916. aBc
  2917. 0: aBc
  2918. \= Expect no match
  2919. Ab
  2920. No match
  2921. abC
  2922. No match
  2923. aBC
  2924. No match
  2925. /(?<=a(?i)b)(\w\w)c/
  2926. abxxc
  2927. 0: xxc
  2928. 1: xx
  2929. aBxxc
  2930. 0: xxc
  2931. 1: xx
  2932. \= Expect no match
  2933. Abxxc
  2934. No match
  2935. ABxxc
  2936. No match
  2937. abxxC
  2938. No match
  2939. /(?:(a)|b)(?(1)A|B)/
  2940. aA
  2941. 0: aA
  2942. 1: a
  2943. bB
  2944. 0: bB
  2945. \= Expect no match
  2946. aB
  2947. No match
  2948. bA
  2949. No match
  2950. /^(a)?(?(1)a|b)+$/
  2951. aa
  2952. 0: aa
  2953. 1: a
  2954. b
  2955. 0: b
  2956. bb
  2957. 0: bb
  2958. \= Expect no match
  2959. ab
  2960. No match
  2961. # Perl gets this next one wrong if the pattern ends with $; in that case it
  2962. # fails to match "12".
  2963. /^(?(?=abc)\w{3}:|\d\d)/
  2964. abc:
  2965. 0: abc:
  2966. 12
  2967. 0: 12
  2968. 123
  2969. 0: 12
  2970. \= Expect no match
  2971. xyz
  2972. No match
  2973. /^(?(?!abc)\d\d|\w{3}:)$/
  2974. abc:
  2975. 0: abc:
  2976. 12
  2977. 0: 12
  2978. \= Expect no match
  2979. 123
  2980. No match
  2981. xyz
  2982. No match
  2983. /(?(?<=foo)bar|cat)/
  2984. foobar
  2985. 0: bar
  2986. cat
  2987. 0: cat
  2988. fcat
  2989. 0: cat
  2990. focat
  2991. 0: cat
  2992. \= Expect no match
  2993. foocat
  2994. No match
  2995. /(?(?<!foo)cat|bar)/
  2996. foobar
  2997. 0: bar
  2998. cat
  2999. 0: cat
  3000. fcat
  3001. 0: cat
  3002. focat
  3003. 0: cat
  3004. \= Expect no match
  3005. foocat
  3006. No match
  3007. /( \( )? [^()]+ (?(1) \) |) /x
  3008. abcd
  3009. 0: abcd
  3010. (abcd)
  3011. 0: (abcd)
  3012. 1: (
  3013. the quick (abcd) fox
  3014. 0: the quick
  3015. (abcd
  3016. 0: abcd
  3017. /( \( )? [^()]+ (?(1) \) ) /x
  3018. abcd
  3019. 0: abcd
  3020. (abcd)
  3021. 0: (abcd)
  3022. 1: (
  3023. the quick (abcd) fox
  3024. 0: the quick
  3025. (abcd
  3026. 0: abcd
  3027. /^(?(2)a|(1)(2))+$/
  3028. 12
  3029. 0: 12
  3030. 1: 1
  3031. 2: 2
  3032. 12a
  3033. 0: 12a
  3034. 1: 1
  3035. 2: 2
  3036. 12aa
  3037. 0: 12aa
  3038. 1: 1
  3039. 2: 2
  3040. \= Expect no match
  3041. 1234
  3042. No match
  3043. /((?i)blah)\s+\1/
  3044. blah blah
  3045. 0: blah blah
  3046. 1: blah
  3047. BLAH BLAH
  3048. 0: BLAH BLAH
  3049. 1: BLAH
  3050. Blah Blah
  3051. 0: Blah Blah
  3052. 1: Blah
  3053. blaH blaH
  3054. 0: blaH blaH
  3055. 1: blaH
  3056. \= Expect no match
  3057. blah BLAH
  3058. No match
  3059. Blah blah
  3060. No match
  3061. blaH blah
  3062. No match
  3063. /((?i)blah)\s+(?i:\1)/
  3064. blah blah
  3065. 0: blah blah
  3066. 1: blah
  3067. BLAH BLAH
  3068. 0: BLAH BLAH
  3069. 1: BLAH
  3070. Blah Blah
  3071. 0: Blah Blah
  3072. 1: Blah
  3073. blaH blaH
  3074. 0: blaH blaH
  3075. 1: blaH
  3076. blah BLAH
  3077. 0: blah BLAH
  3078. 1: blah
  3079. Blah blah
  3080. 0: Blah blah
  3081. 1: Blah
  3082. blaH blah
  3083. 0: blaH blah
  3084. 1: blaH
  3085. /((?i)blah)\s+(?m)A(?i:\1)/
  3086. blah ABLAH
  3087. 0: blah ABLAH
  3088. 1: blah
  3089. \= Expect no match
  3090. blah aBLAH
  3091. No match
  3092. /(?>a*)*/
  3093. a
  3094. 0: a
  3095. aa
  3096. 0: aa
  3097. aaaa
  3098. 0: aaaa
  3099. /(abc|)+/
  3100. abc
  3101. 0: abc
  3102. 1:
  3103. abcabc
  3104. 0: abcabc
  3105. 1:
  3106. abcabcabc
  3107. 0: abcabcabc
  3108. 1:
  3109. xyz
  3110. 0:
  3111. 1:
  3112. /([a]*)*/
  3113. a
  3114. 0: a
  3115. 1:
  3116. aaaaa
  3117. 0: aaaaa
  3118. 1:
  3119. /([ab]*)*/
  3120. a
  3121. 0: a
  3122. 1:
  3123. b
  3124. 0: b
  3125. 1:
  3126. ababab
  3127. 0: ababab
  3128. 1:
  3129. aaaabcde
  3130. 0: aaaab
  3131. 1:
  3132. bbbb
  3133. 0: bbbb
  3134. 1:
  3135. /([^a]*)*/
  3136. b
  3137. 0: b
  3138. 1:
  3139. bbbb
  3140. 0: bbbb
  3141. 1:
  3142. aaa
  3143. 0:
  3144. 1:
  3145. /([^ab]*)*/
  3146. cccc
  3147. 0: cccc
  3148. 1:
  3149. abab
  3150. 0:
  3151. 1:
  3152. /([a]*?)*/
  3153. a
  3154. 0:
  3155. 1:
  3156. aaaa
  3157. 0:
  3158. 1:
  3159. /([ab]*?)*/
  3160. a
  3161. 0:
  3162. 1:
  3163. b
  3164. 0:
  3165. 1:
  3166. abab
  3167. 0:
  3168. 1:
  3169. baba
  3170. 0:
  3171. 1:
  3172. /([^a]*?)*/
  3173. b
  3174. 0:
  3175. 1:
  3176. bbbb
  3177. 0:
  3178. 1:
  3179. aaa
  3180. 0:
  3181. 1:
  3182. /([^ab]*?)*/
  3183. c
  3184. 0:
  3185. 1:
  3186. cccc
  3187. 0:
  3188. 1:
  3189. baba
  3190. 0:
  3191. 1:
  3192. /(?>a*)*/
  3193. a
  3194. 0: a
  3195. aaabcde
  3196. 0: aaa
  3197. /((?>a*))*/
  3198. aaaaa
  3199. 0: aaaaa
  3200. 1:
  3201. aabbaa
  3202. 0: aa
  3203. 1:
  3204. /((?>a*?))*/
  3205. aaaaa
  3206. 0:
  3207. 1:
  3208. aabbaa
  3209. 0:
  3210. 1:
  3211. /(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
  3212. 12-sep-98
  3213. 0: 12-sep-98
  3214. 12-09-98
  3215. 0: 12-09-98
  3216. \= Expect no match
  3217. sep-12-98
  3218. No match
  3219. /(?<=(foo))bar\1/
  3220. foobarfoo
  3221. 0: barfoo
  3222. 1: foo
  3223. foobarfootling
  3224. 0: barfoo
  3225. 1: foo
  3226. \= Expect no match
  3227. foobar
  3228. No match
  3229. barfoo
  3230. No match
  3231. /(?i:saturday|sunday)/
  3232. saturday
  3233. 0: saturday
  3234. sunday
  3235. 0: sunday
  3236. Saturday
  3237. 0: Saturday
  3238. Sunday
  3239. 0: Sunday
  3240. SATURDAY
  3241. 0: SATURDAY
  3242. SUNDAY
  3243. 0: SUNDAY
  3244. SunDay
  3245. 0: SunDay
  3246. /(a(?i)bc|BB)x/
  3247. abcx
  3248. 0: abcx
  3249. 1: abc
  3250. aBCx
  3251. 0: aBCx
  3252. 1: aBC
  3253. bbx
  3254. 0: bbx
  3255. 1: bb
  3256. BBx
  3257. 0: BBx
  3258. 1: BB
  3259. \= Expect no match
  3260. abcX
  3261. No match
  3262. aBCX
  3263. No match
  3264. bbX
  3265. No match
  3266. BBX
  3267. No match
  3268. /^([ab](?i)[cd]|[ef])/
  3269. ac
  3270. 0: ac
  3271. 1: ac
  3272. aC
  3273. 0: aC
  3274. 1: aC
  3275. bD
  3276. 0: bD
  3277. 1: bD
  3278. elephant
  3279. 0: e
  3280. 1: e
  3281. Europe
  3282. 0: E
  3283. 1: E
  3284. frog
  3285. 0: f
  3286. 1: f
  3287. France
  3288. 0: F
  3289. 1: F
  3290. \= Expect no match
  3291. Africa
  3292. No match
  3293. /^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
  3294. ab
  3295. 0: ab
  3296. 1: ab
  3297. aBd
  3298. 0: aBd
  3299. 1: aBd
  3300. xy
  3301. 0: xy
  3302. 1: xy
  3303. xY
  3304. 0: xY
  3305. 1: xY
  3306. zebra
  3307. 0: z
  3308. 1: z
  3309. Zambesi
  3310. 0: Z
  3311. 1: Z
  3312. \= Expect no match
  3313. aCD
  3314. No match
  3315. XY
  3316. No match
  3317. /(?<=foo\n)^bar/m
  3318. foo\nbar
  3319. 0: bar
  3320. \= Expect no match
  3321. bar
  3322. No match
  3323. baz\nbar
  3324. No match
  3325. /(?<=(?<!foo)bar)baz/
  3326. barbaz
  3327. 0: baz
  3328. barbarbaz
  3329. 0: baz
  3330. koobarbaz
  3331. 0: baz
  3332. \= Expect no match
  3333. baz
  3334. No match
  3335. foobarbaz
  3336. No match
  3337. # The cases of aaaa and aaaaaa are missed out below because Perl does things
  3338. # differently. We know that odd, and maybe incorrect, things happen with
  3339. # recursive references in Perl, as far as 5.11.3 - see some stuff in test #2.
  3340. /^(a\1?){4}$/
  3341. aaaaa
  3342. 0: aaaaa
  3343. 1: a
  3344. aaaaaaa
  3345. 0: aaaaaaa
  3346. 1: a
  3347. aaaaaaaaaa
  3348. 0: aaaaaaaaaa
  3349. 1: aaaa
  3350. \= Expect no match
  3351. a
  3352. No match
  3353. aa
  3354. No match
  3355. aaa
  3356. No match
  3357. aaaaaaaa
  3358. No match
  3359. aaaaaaaaa
  3360. No match
  3361. aaaaaaaaaaa
  3362. No match
  3363. aaaaaaaaaaaa
  3364. No match
  3365. aaaaaaaaaaaaa
  3366. No match
  3367. aaaaaaaaaaaaaa
  3368. No match
  3369. aaaaaaaaaaaaaaa
  3370. No match
  3371. aaaaaaaaaaaaaaaa
  3372. No match
  3373. /^(a\1?)(a\1?)(a\2?)(a\3?)$/
  3374. aaaa
  3375. 0: aaaa
  3376. 1: a
  3377. 2: a
  3378. 3: a
  3379. 4: a
  3380. aaaaa
  3381. 0: aaaaa
  3382. 1: a
  3383. 2: aa
  3384. 3: a
  3385. 4: a
  3386. aaaaaa
  3387. 0: aaaaaa
  3388. 1: a
  3389. 2: aa
  3390. 3: a
  3391. 4: aa
  3392. aaaaaaa
  3393. 0: aaaaaaa
  3394. 1: a
  3395. 2: aa
  3396. 3: aaa
  3397. 4: a
  3398. aaaaaaaaaa
  3399. 0: aaaaaaaaaa
  3400. 1: a
  3401. 2: aa
  3402. 3: aaa
  3403. 4: aaaa
  3404. \= Expect no match
  3405. a
  3406. No match
  3407. aa
  3408. No match
  3409. aaa
  3410. No match
  3411. aaaaaaaa
  3412. No match
  3413. aaaaaaaaa
  3414. No match
  3415. aaaaaaaaaaa
  3416. No match
  3417. aaaaaaaaaaaa
  3418. No match
  3419. aaaaaaaaaaaaa
  3420. No match
  3421. aaaaaaaaaaaaaa
  3422. No match
  3423. aaaaaaaaaaaaaaa
  3424. No match
  3425. aaaaaaaaaaaaaaaa
  3426. No match
  3427. # The following tests are taken from the Perl 5.005 test suite; some of them
  3428. # are compatible with 5.004, but I'd rather not have to sort them out.
  3429. /abc/
  3430. abc
  3431. 0: abc
  3432. xabcy
  3433. 0: abc
  3434. ababc
  3435. 0: abc
  3436. \= Expect no match
  3437. xbc
  3438. No match
  3439. axc
  3440. No match
  3441. abx
  3442. No match
  3443. /ab*c/
  3444. abc
  3445. 0: abc
  3446. /ab*bc/
  3447. abc
  3448. 0: abc
  3449. abbc
  3450. 0: abbc
  3451. abbbbc
  3452. 0: abbbbc
  3453. /.{1}/
  3454. abbbbc
  3455. 0: a
  3456. /.{3,4}/
  3457. abbbbc
  3458. 0: abbb
  3459. /ab{0,}bc/
  3460. abbbbc
  3461. 0: abbbbc
  3462. /ab+bc/
  3463. abbc
  3464. 0: abbc
  3465. \= Expect no match
  3466. abc
  3467. No match
  3468. abq
  3469. No match
  3470. /ab{1,}bc/
  3471. /ab+bc/
  3472. abbbbc
  3473. 0: abbbbc
  3474. /ab{1,}bc/
  3475. abbbbc
  3476. 0: abbbbc
  3477. /ab{1,3}bc/
  3478. abbbbc
  3479. 0: abbbbc
  3480. /ab{3,4}bc/
  3481. abbbbc
  3482. 0: abbbbc
  3483. /ab{4,5}bc/
  3484. \= Expect no match
  3485. abq
  3486. No match
  3487. abbbbc
  3488. No match
  3489. /ab?bc/
  3490. abbc
  3491. 0: abbc
  3492. abc
  3493. 0: abc
  3494. /ab{0,1}bc/
  3495. abc
  3496. 0: abc
  3497. /ab?bc/
  3498. /ab?c/
  3499. abc
  3500. 0: abc
  3501. /ab{0,1}c/
  3502. abc
  3503. 0: abc
  3504. /^abc$/
  3505. abc
  3506. 0: abc
  3507. \= Expect no match
  3508. abbbbc
  3509. No match
  3510. abcc
  3511. No match
  3512. /^abc/
  3513. abcc
  3514. 0: abc
  3515. /^abc$/
  3516. /abc$/
  3517. aabc
  3518. 0: abc
  3519. \= Expect no match
  3520. aabcd
  3521. No match
  3522. /^/
  3523. abc
  3524. 0:
  3525. /$/
  3526. abc
  3527. 0:
  3528. /a.c/
  3529. abc
  3530. 0: abc
  3531. axc
  3532. 0: axc
  3533. /a.*c/
  3534. axyzc
  3535. 0: axyzc
  3536. /a[bc]d/
  3537. abd
  3538. 0: abd
  3539. \= Expect no match
  3540. axyzd
  3541. No match
  3542. abc
  3543. No match
  3544. /a[b-d]e/
  3545. ace
  3546. 0: ace
  3547. /a[b-d]/
  3548. aac
  3549. 0: ac
  3550. /a[-b]/
  3551. a-
  3552. 0: a-
  3553. /a[b-]/
  3554. a-
  3555. 0: a-
  3556. /a]/
  3557. a]
  3558. 0: a]
  3559. /a[]]b/
  3560. a]b
  3561. 0: a]b
  3562. /a[^bc]d/
  3563. aed
  3564. 0: aed
  3565. \= Expect no match
  3566. abd
  3567. No match
  3568. abd
  3569. No match
  3570. /a[^-b]c/
  3571. adc
  3572. 0: adc
  3573. /a[^]b]c/
  3574. adc
  3575. 0: adc
  3576. a-c
  3577. 0: a-c
  3578. \= Expect no match
  3579. a]c
  3580. No match
  3581. /\ba\b/
  3582. a-
  3583. 0: a
  3584. -a
  3585. 0: a
  3586. -a-
  3587. 0: a
  3588. /\by\b/
  3589. \= Expect no match
  3590. xy
  3591. No match
  3592. yz
  3593. No match
  3594. xyz
  3595. No match
  3596. /\Ba\B/
  3597. \= Expect no match
  3598. a-
  3599. No match
  3600. -a
  3601. No match
  3602. -a-
  3603. No match
  3604. /\By\b/
  3605. xy
  3606. 0: y
  3607. /\by\B/
  3608. yz
  3609. 0: y
  3610. /\By\B/
  3611. xyz
  3612. 0: y
  3613. /\w/
  3614. a
  3615. 0: a
  3616. /\W/
  3617. -
  3618. 0: -
  3619. \= Expect no match
  3620. a
  3621. No match
  3622. /a\sb/
  3623. a b
  3624. 0: a b
  3625. /a\Sb/
  3626. a-b
  3627. 0: a-b
  3628. \= Expect no match
  3629. a b
  3630. No match
  3631. /\d/
  3632. 1
  3633. 0: 1
  3634. /\D/
  3635. -
  3636. 0: -
  3637. \= Expect no match
  3638. 1
  3639. No match
  3640. /[\w]/
  3641. a
  3642. 0: a
  3643. /[\W]/
  3644. -
  3645. 0: -
  3646. \= Expect no match
  3647. a
  3648. No match
  3649. /a[\s]b/
  3650. a b
  3651. 0: a b
  3652. /a[\S]b/
  3653. a-b
  3654. 0: a-b
  3655. \= Expect no match
  3656. a b
  3657. No match
  3658. /[\d]/
  3659. 1
  3660. 0: 1
  3661. /[\D]/
  3662. -
  3663. 0: -
  3664. \= Expect no match
  3665. 1
  3666. No match
  3667. /ab|cd/
  3668. abc
  3669. 0: ab
  3670. abcd
  3671. 0: ab
  3672. /()ef/
  3673. def
  3674. 0: ef
  3675. 1:
  3676. /$b/
  3677. /a\(b/
  3678. a(b
  3679. 0: a(b
  3680. /a\(*b/
  3681. ab
  3682. 0: ab
  3683. a((b
  3684. 0: a((b
  3685. /a\\b/
  3686. a\\b
  3687. 0: a\b
  3688. /((a))/
  3689. abc
  3690. 0: a
  3691. 1: a
  3692. 2: a
  3693. /(a)b(c)/
  3694. abc
  3695. 0: abc
  3696. 1: a
  3697. 2: c
  3698. /a+b+c/
  3699. aabbabc
  3700. 0: abc
  3701. /a{1,}b{1,}c/
  3702. aabbabc
  3703. 0: abc
  3704. /a.+?c/
  3705. abcabc
  3706. 0: abc
  3707. /(a+|b)*/
  3708. ab
  3709. 0: ab
  3710. 1: b
  3711. /(a+|b){0,}/
  3712. ab
  3713. 0: ab
  3714. 1: b
  3715. /(a+|b)+/
  3716. ab
  3717. 0: ab
  3718. 1: b
  3719. /(a+|b){1,}/
  3720. ab
  3721. 0: ab
  3722. 1: b
  3723. /(a+|b)?/
  3724. ab
  3725. 0: a
  3726. 1: a
  3727. /(a+|b){0,1}/
  3728. ab
  3729. 0: a
  3730. 1: a
  3731. /[^ab]*/
  3732. cde
  3733. 0: cde
  3734. /abc/
  3735. \= Expect no match
  3736. b
  3737. No match
  3738. /a*/
  3739. \
  3740. 0:
  3741. /([abc])*d/
  3742. abbbcd
  3743. 0: abbbcd
  3744. 1: c
  3745. /([abc])*bcd/
  3746. abcd
  3747. 0: abcd
  3748. 1: a
  3749. /a|b|c|d|e/
  3750. e
  3751. 0: e
  3752. /(a|b|c|d|e)f/
  3753. ef
  3754. 0: ef
  3755. 1: e
  3756. /abcd*efg/
  3757. abcdefg
  3758. 0: abcdefg
  3759. /ab*/
  3760. xabyabbbz
  3761. 0: ab
  3762. xayabbbz
  3763. 0: a
  3764. /(ab|cd)e/
  3765. abcde
  3766. 0: cde
  3767. 1: cd
  3768. /[abhgefdc]ij/
  3769. hij
  3770. 0: hij
  3771. /^(ab|cd)e/
  3772. /(abc|)ef/
  3773. abcdef
  3774. 0: ef
  3775. 1:
  3776. /(a|b)c*d/
  3777. abcd
  3778. 0: bcd
  3779. 1: b
  3780. /(ab|ab*)bc/
  3781. abc
  3782. 0: abc
  3783. 1: a
  3784. /a([bc]*)c*/
  3785. abc
  3786. 0: abc
  3787. 1: bc
  3788. /a([bc]*)(c*d)/
  3789. abcd
  3790. 0: abcd
  3791. 1: bc
  3792. 2: d
  3793. /a([bc]+)(c*d)/
  3794. abcd
  3795. 0: abcd
  3796. 1: bc
  3797. 2: d
  3798. /a([bc]*)(c+d)/
  3799. abcd
  3800. 0: abcd
  3801. 1: b
  3802. 2: cd
  3803. /a[bcd]*dcdcde/
  3804. adcdcde
  3805. 0: adcdcde
  3806. /a[bcd]+dcdcde/
  3807. \= Expect no match
  3808. abcde
  3809. No match
  3810. adcdcde
  3811. No match
  3812. /(ab|a)b*c/
  3813. abc
  3814. 0: abc
  3815. 1: ab
  3816. /((a)(b)c)(d)/
  3817. abcd
  3818. 0: abcd
  3819. 1: abc
  3820. 2: a
  3821. 3: b
  3822. 4: d
  3823. /[a-zA-Z_][a-zA-Z0-9_]*/
  3824. alpha
  3825. 0: alpha
  3826. /^a(bc+|b[eh])g|.h$/
  3827. abh
  3828. 0: bh
  3829. /(bc+d$|ef*g.|h?i(j|k))/
  3830. effgz
  3831. 0: effgz
  3832. 1: effgz
  3833. ij
  3834. 0: ij
  3835. 1: ij
  3836. 2: j
  3837. reffgz
  3838. 0: effgz
  3839. 1: effgz
  3840. \= Expect no match
  3841. effg
  3842. No match
  3843. bcdd
  3844. No match
  3845. /((((((((((a))))))))))/
  3846. a
  3847. 0: a
  3848. 1: a
  3849. 2: a
  3850. 3: a
  3851. 4: a
  3852. 5: a
  3853. 6: a
  3854. 7: a
  3855. 8: a
  3856. 9: a
  3857. 10: a
  3858. /((((((((((a))))))))))\10/
  3859. aa
  3860. 0: aa
  3861. 1: a
  3862. 2: a
  3863. 3: a
  3864. 4: a
  3865. 5: a
  3866. 6: a
  3867. 7: a
  3868. 8: a
  3869. 9: a
  3870. 10: a
  3871. /(((((((((a)))))))))/
  3872. a
  3873. 0: a
  3874. 1: a
  3875. 2: a
  3876. 3: a
  3877. 4: a
  3878. 5: a
  3879. 6: a
  3880. 7: a
  3881. 8: a
  3882. 9: a
  3883. /multiple words of text/
  3884. \= Expect no match
  3885. aa
  3886. No match
  3887. uh-uh
  3888. No match
  3889. /multiple words/
  3890. multiple words, yeah
  3891. 0: multiple words
  3892. /(.*)c(.*)/
  3893. abcde
  3894. 0: abcde
  3895. 1: ab
  3896. 2: de
  3897. /\((.*), (.*)\)/
  3898. (a, b)
  3899. 0: (a, b)
  3900. 1: a
  3901. 2: b
  3902. /[k]/
  3903. /abcd/
  3904. abcd
  3905. 0: abcd
  3906. /a(bc)d/
  3907. abcd
  3908. 0: abcd
  3909. 1: bc
  3910. /a[-]?c/
  3911. ac
  3912. 0: ac
  3913. /(abc)\1/
  3914. abcabc
  3915. 0: abcabc
  3916. 1: abc
  3917. /([a-c]*)\1/
  3918. abcabc
  3919. 0: abcabc
  3920. 1: abc
  3921. /(a)|\1/
  3922. a
  3923. 0: a
  3924. 1: a
  3925. ab
  3926. 0: a
  3927. 1: a
  3928. \= Expect no match
  3929. x
  3930. No match
  3931. /(([a-c])b*?\2)*/
  3932. ababbbcbc
  3933. 0: ababb
  3934. 1: bb
  3935. 2: b
  3936. /(([a-c])b*?\2){3}/
  3937. ababbbcbc
  3938. 0: ababbbcbc
  3939. 1: cbc
  3940. 2: c
  3941. /((\3|b)\2(a)x)+/
  3942. aaaxabaxbaaxbbax
  3943. 0: bbax
  3944. 1: bbax
  3945. 2: b
  3946. 3: a
  3947. /((\3|b)\2(a)){2,}/
  3948. bbaababbabaaaaabbaaaabba
  3949. 0: bbaaaabba
  3950. 1: bba
  3951. 2: b
  3952. 3: a
  3953. /abc/i
  3954. ABC
  3955. 0: ABC
  3956. XABCY
  3957. 0: ABC
  3958. ABABC
  3959. 0: ABC
  3960. \= Expect no match
  3961. aaxabxbaxbbx
  3962. No match
  3963. XBC
  3964. No match
  3965. AXC
  3966. No match
  3967. ABX
  3968. No match
  3969. /ab*c/i
  3970. ABC
  3971. 0: ABC
  3972. /ab*bc/i
  3973. ABC
  3974. 0: ABC
  3975. ABBC
  3976. 0: ABBC
  3977. /ab*?bc/i
  3978. ABBBBC
  3979. 0: ABBBBC
  3980. /ab{0,}?bc/i
  3981. ABBBBC
  3982. 0: ABBBBC
  3983. /ab+?bc/i
  3984. ABBC
  3985. 0: ABBC
  3986. /ab+bc/i
  3987. \= Expect no match
  3988. ABC
  3989. No match
  3990. ABQ
  3991. No match
  3992. /ab{1,}bc/i
  3993. /ab+bc/i
  3994. ABBBBC
  3995. 0: ABBBBC
  3996. /ab{1,}?bc/i
  3997. ABBBBC
  3998. 0: ABBBBC
  3999. /ab{1,3}?bc/i
  4000. ABBBBC
  4001. 0: ABBBBC
  4002. /ab{3,4}?bc/i
  4003. ABBBBC
  4004. 0: ABBBBC
  4005. /ab{4,5}?bc/i
  4006. \= Expect no match
  4007. ABQ
  4008. No match
  4009. ABBBBC
  4010. No match
  4011. /ab??bc/i
  4012. ABBC
  4013. 0: ABBC
  4014. ABC
  4015. 0: ABC
  4016. /ab{0,1}?bc/i
  4017. ABC
  4018. 0: ABC
  4019. /ab??bc/i
  4020. /ab??c/i
  4021. ABC
  4022. 0: ABC
  4023. /ab{0,1}?c/i
  4024. ABC
  4025. 0: ABC
  4026. /^abc$/i
  4027. ABC
  4028. 0: ABC
  4029. \= Expect no match
  4030. ABBBBC
  4031. No match
  4032. ABCC
  4033. No match
  4034. /^abc/i
  4035. ABCC
  4036. 0: ABC
  4037. /^abc$/i
  4038. /abc$/i
  4039. AABC
  4040. 0: ABC
  4041. /^/i
  4042. ABC
  4043. 0:
  4044. /$/i
  4045. ABC
  4046. 0:
  4047. /a.c/i
  4048. ABC
  4049. 0: ABC
  4050. AXC
  4051. 0: AXC
  4052. /a.*?c/i
  4053. AXYZC
  4054. 0: AXYZC
  4055. /a.*c/i
  4056. AABC
  4057. 0: AABC
  4058. \= Expect no match
  4059. AXYZD
  4060. No match
  4061. /a[bc]d/i
  4062. ABD
  4063. 0: ABD
  4064. /a[b-d]e/i
  4065. ACE
  4066. 0: ACE
  4067. \= Expect no match
  4068. ABC
  4069. No match
  4070. ABD
  4071. No match
  4072. /a[b-d]/i
  4073. AAC
  4074. 0: AC
  4075. /a[-b]/i
  4076. A-
  4077. 0: A-
  4078. /a[b-]/i
  4079. A-
  4080. 0: A-
  4081. /a]/i
  4082. A]
  4083. 0: A]
  4084. /a[]]b/i
  4085. A]B
  4086. 0: A]B
  4087. /a[^bc]d/i
  4088. AED
  4089. 0: AED
  4090. /a[^-b]c/i
  4091. ADC
  4092. 0: ADC
  4093. \= Expect no match
  4094. ABD
  4095. No match
  4096. A-C
  4097. No match
  4098. /a[^]b]c/i
  4099. ADC
  4100. 0: ADC
  4101. /ab|cd/i
  4102. ABC
  4103. 0: AB
  4104. ABCD
  4105. 0: AB
  4106. /()ef/i
  4107. DEF
  4108. 0: EF
  4109. 1:
  4110. /$b/i
  4111. \= Expect no match
  4112. A]C
  4113. No match
  4114. B
  4115. No match
  4116. /a\(b/i
  4117. A(B
  4118. 0: A(B
  4119. /a\(*b/i
  4120. AB
  4121. 0: AB
  4122. A((B
  4123. 0: A((B
  4124. /a\\b/i
  4125. A\\b
  4126. 0: A\b
  4127. a\\B
  4128. 0: a\B
  4129. /((a))/i
  4130. ABC
  4131. 0: A
  4132. 1: A
  4133. 2: A
  4134. /(a)b(c)/i
  4135. ABC
  4136. 0: ABC
  4137. 1: A
  4138. 2: C
  4139. /a+b+c/i
  4140. AABBABC
  4141. 0: ABC
  4142. /a{1,}b{1,}c/i
  4143. AABBABC
  4144. 0: ABC
  4145. /a.+?c/i
  4146. ABCABC
  4147. 0: ABC
  4148. /a.*?c/i
  4149. ABCABC
  4150. 0: ABC
  4151. /a.{0,5}?c/i
  4152. ABCABC
  4153. 0: ABC
  4154. /(a+|b)*/i
  4155. AB
  4156. 0: AB
  4157. 1: B
  4158. /(a+|b){0,}/i
  4159. AB
  4160. 0: AB
  4161. 1: B
  4162. /(a+|b)+/i
  4163. AB
  4164. 0: AB
  4165. 1: B
  4166. /(a+|b){1,}/i
  4167. AB
  4168. 0: AB
  4169. 1: B
  4170. /(a+|b)?/i
  4171. AB
  4172. 0: A
  4173. 1: A
  4174. /(a+|b){0,1}/i
  4175. AB
  4176. 0: A
  4177. 1: A
  4178. /(a+|b){0,1}?/i
  4179. AB
  4180. 0:
  4181. /[^ab]*/i
  4182. CDE
  4183. 0: CDE
  4184. /([abc])*d/i
  4185. ABBBCD
  4186. 0: ABBBCD
  4187. 1: C
  4188. /([abc])*bcd/i
  4189. ABCD
  4190. 0: ABCD
  4191. 1: A
  4192. /a|b|c|d|e/i
  4193. E
  4194. 0: E
  4195. /(a|b|c|d|e)f/i
  4196. EF
  4197. 0: EF
  4198. 1: E
  4199. /abcd*efg/i
  4200. ABCDEFG
  4201. 0: ABCDEFG
  4202. /ab*/i
  4203. XABYABBBZ
  4204. 0: AB
  4205. XAYABBBZ
  4206. 0: A
  4207. /(ab|cd)e/i
  4208. ABCDE
  4209. 0: CDE
  4210. 1: CD
  4211. /[abhgefdc]ij/i
  4212. HIJ
  4213. 0: HIJ
  4214. /^(ab|cd)e/i
  4215. \= Expect no match
  4216. ABCDE
  4217. No match
  4218. /(abc|)ef/i
  4219. ABCDEF
  4220. 0: EF
  4221. 1:
  4222. /(a|b)c*d/i
  4223. ABCD
  4224. 0: BCD
  4225. 1: B
  4226. /(ab|ab*)bc/i
  4227. ABC
  4228. 0: ABC
  4229. 1: A
  4230. /a([bc]*)c*/i
  4231. ABC
  4232. 0: ABC
  4233. 1: BC
  4234. /a([bc]*)(c*d)/i
  4235. ABCD
  4236. 0: ABCD
  4237. 1: BC
  4238. 2: D
  4239. /a([bc]+)(c*d)/i
  4240. ABCD
  4241. 0: ABCD
  4242. 1: BC
  4243. 2: D
  4244. /a([bc]*)(c+d)/i
  4245. ABCD
  4246. 0: ABCD
  4247. 1: B
  4248. 2: CD
  4249. /a[bcd]*dcdcde/i
  4250. ADCDCDE
  4251. 0: ADCDCDE
  4252. /a[bcd]+dcdcde/i
  4253. /(ab|a)b*c/i
  4254. ABC
  4255. 0: ABC
  4256. 1: AB
  4257. /((a)(b)c)(d)/i
  4258. ABCD
  4259. 0: ABCD
  4260. 1: ABC
  4261. 2: A
  4262. 3: B
  4263. 4: D
  4264. /[a-zA-Z_][a-zA-Z0-9_]*/i
  4265. ALPHA
  4266. 0: ALPHA
  4267. /^a(bc+|b[eh])g|.h$/i
  4268. ABH
  4269. 0: BH
  4270. /(bc+d$|ef*g.|h?i(j|k))/i
  4271. EFFGZ
  4272. 0: EFFGZ
  4273. 1: EFFGZ
  4274. IJ
  4275. 0: IJ
  4276. 1: IJ
  4277. 2: J
  4278. REFFGZ
  4279. 0: EFFGZ
  4280. 1: EFFGZ
  4281. \= Expect no match
  4282. ADCDCDE
  4283. No match
  4284. EFFG
  4285. No match
  4286. BCDD
  4287. No match
  4288. /((((((((((a))))))))))/i
  4289. A
  4290. 0: A
  4291. 1: A
  4292. 2: A
  4293. 3: A
  4294. 4: A
  4295. 5: A
  4296. 6: A
  4297. 7: A
  4298. 8: A
  4299. 9: A
  4300. 10: A
  4301. /((((((((((a))))))))))\10/i
  4302. AA
  4303. 0: AA
  4304. 1: A
  4305. 2: A
  4306. 3: A
  4307. 4: A
  4308. 5: A
  4309. 6: A
  4310. 7: A
  4311. 8: A
  4312. 9: A
  4313. 10: A
  4314. /(((((((((a)))))))))/i
  4315. A
  4316. 0: A
  4317. 1: A
  4318. 2: A
  4319. 3: A
  4320. 4: A
  4321. 5: A
  4322. 6: A
  4323. 7: A
  4324. 8: A
  4325. 9: A
  4326. /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
  4327. A
  4328. 0: A
  4329. 1: A
  4330. /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
  4331. C
  4332. 0: C
  4333. 1: C
  4334. /multiple words of text/i
  4335. \= Expect no match
  4336. AA
  4337. No match
  4338. UH-UH
  4339. No match
  4340. /multiple words/i
  4341. MULTIPLE WORDS, YEAH
  4342. 0: MULTIPLE WORDS
  4343. /(.*)c(.*)/i
  4344. ABCDE
  4345. 0: ABCDE
  4346. 1: AB
  4347. 2: DE
  4348. /\((.*), (.*)\)/i
  4349. (A, B)
  4350. 0: (A, B)
  4351. 1: A
  4352. 2: B
  4353. /[k]/i
  4354. /abcd/i
  4355. ABCD
  4356. 0: ABCD
  4357. /a(bc)d/i
  4358. ABCD
  4359. 0: ABCD
  4360. 1: BC
  4361. /a[-]?c/i
  4362. AC
  4363. 0: AC
  4364. /(abc)\1/i
  4365. ABCABC
  4366. 0: ABCABC
  4367. 1: ABC
  4368. /([a-c]*)\1/i
  4369. ABCABC
  4370. 0: ABCABC
  4371. 1: ABC
  4372. /a(?!b)./
  4373. abad
  4374. 0: ad
  4375. /a(?=d)./
  4376. abad
  4377. 0: ad
  4378. /a(?=c|d)./
  4379. abad
  4380. 0: ad
  4381. /a(?:b|c|d)(.)/
  4382. ace
  4383. 0: ace
  4384. 1: e
  4385. /a(?:b|c|d)*(.)/
  4386. ace
  4387. 0: ace
  4388. 1: e
  4389. /a(?:b|c|d)+?(.)/
  4390. ace
  4391. 0: ace
  4392. 1: e
  4393. acdbcdbe
  4394. 0: acd
  4395. 1: d
  4396. /a(?:b|c|d)+(.)/
  4397. acdbcdbe
  4398. 0: acdbcdbe
  4399. 1: e
  4400. /a(?:b|c|d){2}(.)/
  4401. acdbcdbe
  4402. 0: acdb
  4403. 1: b
  4404. /a(?:b|c|d){4,5}(.)/
  4405. acdbcdbe
  4406. 0: acdbcdb
  4407. 1: b
  4408. /a(?:b|c|d){4,5}?(.)/
  4409. acdbcdbe
  4410. 0: acdbcd
  4411. 1: d
  4412. /a(?:b|c|d){6,7}(.)/
  4413. acdbcdbe
  4414. 0: acdbcdbe
  4415. 1: e
  4416. /a(?:b|c|d){6,7}?(.)/
  4417. acdbcdbe
  4418. 0: acdbcdbe
  4419. 1: e
  4420. /a(?:b|c|d){5,6}(.)/
  4421. acdbcdbe
  4422. 0: acdbcdbe
  4423. 1: e
  4424. /a(?:b|c|d){5,6}?(.)/
  4425. acdbcdbe
  4426. 0: acdbcdb
  4427. 1: b
  4428. /a(?:b|c|d){5,7}(.)/
  4429. acdbcdbe
  4430. 0: acdbcdbe
  4431. 1: e
  4432. /a(?:b|c|d){5,7}?(.)/
  4433. acdbcdbe
  4434. 0: acdbcdb
  4435. 1: b
  4436. /a(?:b|(c|e){1,2}?|d)+?(.)/
  4437. ace
  4438. 0: ace
  4439. 1: c
  4440. 2: e
  4441. /^(.+)?B/
  4442. AB
  4443. 0: AB
  4444. 1: A
  4445. /^([^a-z])|(\^)$/
  4446. .
  4447. 0: .
  4448. 1: .
  4449. /^[<>]&/
  4450. <&OUT
  4451. 0: <&
  4452. /^(a\1?){4}$/
  4453. aaaaaaaaaa
  4454. 0: aaaaaaaaaa
  4455. 1: aaaa
  4456. \= Expect no match
  4457. AB
  4458. No match
  4459. aaaaaaaaa
  4460. No match
  4461. aaaaaaaaaaa
  4462. No match
  4463. /^(a(?(1)\1)){4}$/
  4464. aaaaaaaaaa
  4465. 0: aaaaaaaaaa
  4466. 1: aaaa
  4467. \= Expect no match
  4468. aaaaaaaaa
  4469. No match
  4470. aaaaaaaaaaa
  4471. No match
  4472. /(?<=a)b/
  4473. ab
  4474. 0: b
  4475. \= Expect no match
  4476. cb
  4477. No match
  4478. b
  4479. No match
  4480. /(?<!c)b/
  4481. ab
  4482. 0: b
  4483. b
  4484. 0: b
  4485. b
  4486. 0: b
  4487. /(?:..)*a/
  4488. aba
  4489. 0: aba
  4490. /(?:..)*?a/
  4491. aba
  4492. 0: a
  4493. /^(?:b|a(?=(.)))*\1/
  4494. abc
  4495. 0: ab
  4496. 1: b
  4497. /^(){3,5}/
  4498. abc
  4499. 0:
  4500. 1:
  4501. /^(a+)*ax/
  4502. aax
  4503. 0: aax
  4504. 1: a
  4505. /^((a|b)+)*ax/
  4506. aax
  4507. 0: aax
  4508. 1: a
  4509. 2: a
  4510. /^((a|bc)+)*ax/
  4511. aax
  4512. 0: aax
  4513. 1: a
  4514. 2: a
  4515. /(a|x)*ab/
  4516. cab
  4517. 0: ab
  4518. /(a)*ab/
  4519. cab
  4520. 0: ab
  4521. /(?:(?i)a)b/
  4522. ab
  4523. 0: ab
  4524. /((?i)a)b/
  4525. ab
  4526. 0: ab
  4527. 1: a
  4528. /(?:(?i)a)b/
  4529. Ab
  4530. 0: Ab
  4531. /((?i)a)b/
  4532. Ab
  4533. 0: Ab
  4534. 1: A
  4535. /(?:(?i)a)b/
  4536. \= Expect no match
  4537. cb
  4538. No match
  4539. aB
  4540. No match
  4541. /((?i)a)b/
  4542. /(?i:a)b/
  4543. ab
  4544. 0: ab
  4545. /((?i:a))b/
  4546. ab
  4547. 0: ab
  4548. 1: a
  4549. /(?i:a)b/
  4550. Ab
  4551. 0: Ab
  4552. /((?i:a))b/
  4553. Ab
  4554. 0: Ab
  4555. 1: A
  4556. /(?i:a)b/
  4557. \= Expect no match
  4558. aB
  4559. No match
  4560. aB
  4561. No match
  4562. /((?i:a))b/
  4563. /(?:(?-i)a)b/i
  4564. ab
  4565. 0: ab
  4566. /((?-i)a)b/i
  4567. ab
  4568. 0: ab
  4569. 1: a
  4570. /(?:(?-i)a)b/i
  4571. aB
  4572. 0: aB
  4573. /((?-i)a)b/i
  4574. aB
  4575. 0: aB
  4576. 1: a
  4577. /(?:(?-i)a)b/i
  4578. aB
  4579. 0: aB
  4580. \= Expect no match
  4581. Ab
  4582. No match
  4583. AB
  4584. No match
  4585. /(?-i:a)b/i
  4586. ab
  4587. 0: ab
  4588. /((?-i:a))b/i
  4589. ab
  4590. 0: ab
  4591. 1: a
  4592. /(?-i:a)b/i
  4593. aB
  4594. 0: aB
  4595. /((?-i:a))b/i
  4596. aB
  4597. 0: aB
  4598. 1: a
  4599. /(?-i:a)b/i
  4600. \= Expect no match
  4601. AB
  4602. No match
  4603. Ab
  4604. No match
  4605. /((?-i:a))b/i
  4606. /(?-i:a)b/i
  4607. aB
  4608. 0: aB
  4609. /((?-i:a))b/i
  4610. aB
  4611. 0: aB
  4612. 1: a
  4613. /(?-i:a)b/i
  4614. \= Expect no match
  4615. Ab
  4616. No match
  4617. AB
  4618. No match
  4619. /((?-i:a))b/i
  4620. /((?-i:a.))b/i
  4621. \= Expect no match
  4622. AB
  4623. No match
  4624. a\nB
  4625. No match
  4626. /((?s-i:a.))b/i
  4627. a\nB
  4628. 0: a\x0aB
  4629. 1: a\x0a
  4630. /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
  4631. cabbbb
  4632. 0: cabbbb
  4633. /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
  4634. caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  4635. 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  4636. /(ab)\d\1/i
  4637. Ab4ab
  4638. 0: Ab4ab
  4639. 1: Ab
  4640. ab4Ab
  4641. 0: ab4Ab
  4642. 1: ab
  4643. /foo\w*\d{4}baz/
  4644. foobar1234baz
  4645. 0: foobar1234baz
  4646. /x(~~)*(?:(?:F)?)?/
  4647. x~~
  4648. 0: x~~
  4649. 1: ~~
  4650. /^a(?#xxx){3}c/
  4651. aaac
  4652. 0: aaac
  4653. /^a (?#xxx) (?#yyy) {3}c/x
  4654. aaac
  4655. 0: aaac
  4656. /(?<![cd])b/
  4657. \= Expect no match
  4658. B\nB
  4659. No match
  4660. dbcb
  4661. No match
  4662. /(?<![cd])[ab]/
  4663. dbaacb
  4664. 0: a
  4665. /(?<!(c|d))b/
  4666. /(?<!(c|d))[ab]/
  4667. dbaacb
  4668. 0: a
  4669. /(?<!cd)[ab]/
  4670. cdaccb
  4671. 0: b
  4672. /^(?:a?b?)*$/
  4673. \
  4674. 0:
  4675. a
  4676. 0: a
  4677. ab
  4678. 0: ab
  4679. aaa
  4680. 0: aaa
  4681. \= Expect no match
  4682. dbcb
  4683. No match
  4684. a--
  4685. No match
  4686. aa--
  4687. No match
  4688. /((?s)^a(.))((?m)^b$)/
  4689. a\nb\nc\n
  4690. 0: a\x0ab
  4691. 1: a\x0a
  4692. 2: \x0a
  4693. 3: b
  4694. /((?m)^b$)/
  4695. a\nb\nc\n
  4696. 0: b
  4697. 1: b
  4698. /(?m)^b/
  4699. a\nb\n
  4700. 0: b
  4701. /(?m)^(b)/
  4702. a\nb\n
  4703. 0: b
  4704. 1: b
  4705. /((?m)^b)/
  4706. a\nb\n
  4707. 0: b
  4708. 1: b
  4709. /\n((?m)^b)/
  4710. a\nb\n
  4711. 0: \x0ab
  4712. 1: b
  4713. /((?s).)c(?!.)/
  4714. a\nb\nc\n
  4715. 0: \x0ac
  4716. 1: \x0a
  4717. a\nb\nc\n
  4718. 0: \x0ac
  4719. 1: \x0a
  4720. /((?s)b.)c(?!.)/
  4721. a\nb\nc\n
  4722. 0: b\x0ac
  4723. 1: b\x0a
  4724. a\nb\nc\n
  4725. 0: b\x0ac
  4726. 1: b\x0a
  4727. /^b/
  4728. /()^b/
  4729. \= Expect no match
  4730. a\nb\nc\n
  4731. No match
  4732. a\nb\nc\n
  4733. No match
  4734. /((?m)^b)/
  4735. a\nb\nc\n
  4736. 0: b
  4737. 1: b
  4738. /(x)?(?(1)a|b)/
  4739. \= Expect no match
  4740. a
  4741. No match
  4742. a
  4743. No match
  4744. /(x)?(?(1)b|a)/
  4745. a
  4746. 0: a
  4747. /()?(?(1)b|a)/
  4748. a
  4749. 0: a
  4750. /()(?(1)b|a)/
  4751. /()?(?(1)a|b)/
  4752. a
  4753. 0: a
  4754. 1:
  4755. /^(\()?blah(?(1)(\)))$/
  4756. (blah)
  4757. 0: (blah)
  4758. 1: (
  4759. 2: )
  4760. blah
  4761. 0: blah
  4762. \= Expect no match
  4763. a
  4764. No match
  4765. blah)
  4766. No match
  4767. (blah
  4768. No match
  4769. /^(\(+)?blah(?(1)(\)))$/
  4770. (blah)
  4771. 0: (blah)
  4772. 1: (
  4773. 2: )
  4774. blah
  4775. 0: blah
  4776. \= Expect no match
  4777. blah)
  4778. No match
  4779. (blah
  4780. No match
  4781. /(?(?!a)a|b)/
  4782. /(?(?!a)b|a)/
  4783. a
  4784. 0: a
  4785. /(?(?=a)b|a)/
  4786. \= Expect no match
  4787. a
  4788. No match
  4789. a
  4790. No match
  4791. /(?(?=a)a|b)/
  4792. a
  4793. 0: a
  4794. /(?=(a+?))(\1ab)/
  4795. aaab
  4796. 0: aab
  4797. 1: a
  4798. 2: aab
  4799. /^(?=(a+?))\1ab/
  4800. /(\w+:)+/
  4801. one:
  4802. 0: one:
  4803. 1: one:
  4804. /$(?<=^(a))/
  4805. a
  4806. 0:
  4807. 1: a
  4808. /(?=(a+?))(\1ab)/
  4809. aaab
  4810. 0: aab
  4811. 1: a
  4812. 2: aab
  4813. /^(?=(a+?))\1ab/
  4814. \= Expect no match
  4815. aaab
  4816. No match
  4817. aaab
  4818. No match
  4819. /([\w:]+::)?(\w+)$/
  4820. abcd
  4821. 0: abcd
  4822. 1: <unset>
  4823. 2: abcd
  4824. xy:z:::abcd
  4825. 0: xy:z:::abcd
  4826. 1: xy:z:::
  4827. 2: abcd
  4828. /^[^bcd]*(c+)/
  4829. aexycd
  4830. 0: aexyc
  4831. 1: c
  4832. /(a*)b+/
  4833. caab
  4834. 0: aab
  4835. 1: aa
  4836. /([\w:]+::)?(\w+)$/
  4837. abcd
  4838. 0: abcd
  4839. 1: <unset>
  4840. 2: abcd
  4841. xy:z:::abcd
  4842. 0: xy:z:::abcd
  4843. 1: xy:z:::
  4844. 2: abcd
  4845. \= Expect no match
  4846. abcd:
  4847. No match
  4848. abcd:
  4849. No match
  4850. /^[^bcd]*(c+)/
  4851. aexycd
  4852. 0: aexyc
  4853. 1: c
  4854. /(>a+)ab/
  4855. /(?>a+)b/
  4856. aaab
  4857. 0: aaab
  4858. /([[:]+)/
  4859. a:[b]:
  4860. 0: :[
  4861. 1: :[
  4862. /([[=]+)/
  4863. a=[b]=
  4864. 0: =[
  4865. 1: =[
  4866. /([[.]+)/
  4867. a.[b].
  4868. 0: .[
  4869. 1: .[
  4870. /((?>a+)b)/
  4871. aaab
  4872. 0: aaab
  4873. 1: aaab
  4874. /(?>(a+))b/
  4875. aaab
  4876. 0: aaab
  4877. 1: aaa
  4878. /((?>[^()]+)|\([^()]*\))+/
  4879. ((abc(ade)ufh()()x
  4880. 0: abc(ade)ufh()()x
  4881. 1: x
  4882. /a\Z/
  4883. \= Expect no match
  4884. aaab
  4885. No match
  4886. a\nb\n
  4887. No match
  4888. /b\Z/
  4889. a\nb\n
  4890. 0: b
  4891. /b\z/
  4892. /b\Z/
  4893. a\nb
  4894. 0: b
  4895. /b\z/
  4896. a\nb
  4897. 0: b
  4898. /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
  4899. a
  4900. 0: a
  4901. 1:
  4902. abc
  4903. 0: abc
  4904. 1:
  4905. a-b
  4906. 0: a-b
  4907. 1:
  4908. 0-9
  4909. 0: 0-9
  4910. 1:
  4911. a.b
  4912. 0: a.b
  4913. 1:
  4914. 5.6.7
  4915. 0: 5.6.7
  4916. 1:
  4917. the.quick.brown.fox
  4918. 0: the.quick.brown.fox
  4919. 1:
  4920. a100.b200.300c
  4921. 0: a100.b200.300c
  4922. 1:
  4923. 12-ab.1245
  4924. 0: 12-ab.1245
  4925. 1:
  4926. \= Expect no match
  4927. \
  4928. No match
  4929. .a
  4930. No match
  4931. -a
  4932. No match
  4933. a-
  4934. No match
  4935. a.
  4936. No match
  4937. a_b
  4938. No match
  4939. a.-
  4940. No match
  4941. a..
  4942. No match
  4943. ab..bc
  4944. No match
  4945. the.quick.brown.fox-
  4946. No match
  4947. the.quick.brown.fox.
  4948. No match
  4949. the.quick.brown.fox_
  4950. No match
  4951. the.quick.brown.fox+
  4952. No match
  4953. /(?>.*)(?<=(abcd|wxyz))/
  4954. alphabetabcd
  4955. 0: alphabetabcd
  4956. 1: abcd
  4957. endingwxyz
  4958. 0: endingwxyz
  4959. 1: wxyz
  4960. \= Expect no match
  4961. a rather long string that doesn't end with one of them
  4962. No match
  4963. /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
  4964. word cat dog elephant mussel cow horse canary baboon snake shark otherword
  4965. 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
  4966. \= Expect no match
  4967. word cat dog elephant mussel cow horse canary baboon snake shark
  4968. No match
  4969. /word (?>[a-zA-Z0-9]+ ){0,30}otherword/
  4970. \= Expect no match
  4971. 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
  4972. No match
  4973. /(?<=\d{3}(?!999))foo/
  4974. 999foo
  4975. 0: foo
  4976. 123999foo
  4977. 0: foo
  4978. \= Expect no match
  4979. 123abcfoo
  4980. No match
  4981. /(?<=(?!...999)\d{3})foo/
  4982. 999foo
  4983. 0: foo
  4984. 123999foo
  4985. 0: foo
  4986. \= Expect no match
  4987. 123abcfoo
  4988. No match
  4989. /(?<=\d{3}(?!999)...)foo/
  4990. 123abcfoo
  4991. 0: foo
  4992. 123456foo
  4993. 0: foo
  4994. \= Expect no match
  4995. 123999foo
  4996. No match
  4997. /(?<=\d{3}...)(?<!999)foo/
  4998. 123abcfoo
  4999. 0: foo
  5000. 123456foo
  5001. 0: foo
  5002. \= Expect no match
  5003. 123999foo
  5004. No match
  5005. /<a[\s]+href[\s]*=[\s]* # find <a href=
  5006. ([\"\'])? # find single or double quote
  5007. (?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
  5008. # quote, otherwise match up to next space
  5009. /isx
  5010. <a href=abcd xyz
  5011. 0: <a href=abcd
  5012. 1: <unset>
  5013. 2: <unset>
  5014. 3: abcd
  5015. <a href=\"abcd xyz pqr\" cats
  5016. 0: <a href="abcd xyz pqr"
  5017. 1: "
  5018. 2: abcd xyz pqr
  5019. <a href=\'abcd xyz pqr\' cats
  5020. 0: <a href='abcd xyz pqr'
  5021. 1: '
  5022. 2: abcd xyz pqr
  5023. /<a\s+href\s*=\s* # find <a href=
  5024. (["'])? # find single or double quote
  5025. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  5026. # quote, otherwise match up to next space
  5027. /isx
  5028. <a href=abcd xyz
  5029. 0: <a href=abcd
  5030. 1: <unset>
  5031. 2: <unset>
  5032. 3: abcd
  5033. <a href=\"abcd xyz pqr\" cats
  5034. 0: <a href="abcd xyz pqr"
  5035. 1: "
  5036. 2: abcd xyz pqr
  5037. <a href = \'abcd xyz pqr\' cats
  5038. 0: <a href = 'abcd xyz pqr'
  5039. 1: '
  5040. 2: abcd xyz pqr
  5041. /<a\s+href(?>\s*)=(?>\s*) # find <a href=
  5042. (["'])? # find single or double quote
  5043. (?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
  5044. # quote, otherwise match up to next space
  5045. /isx
  5046. <a href=abcd xyz
  5047. 0: <a href=abcd
  5048. 1: <unset>
  5049. 2: <unset>
  5050. 3: abcd
  5051. <a href=\"abcd xyz pqr\" cats
  5052. 0: <a href="abcd xyz pqr"
  5053. 1: "
  5054. 2: abcd xyz pqr
  5055. <a href = \'abcd xyz pqr\' cats
  5056. 0: <a href = 'abcd xyz pqr'
  5057. 1: '
  5058. 2: abcd xyz pqr
  5059. /(Z()|A)*/
  5060. ZABCDEFG
  5061. 0: ZA
  5062. 1: A
  5063. 2:
  5064. /(Z(())|A)*/
  5065. ZABCDEFG
  5066. 0: ZA
  5067. 1: A
  5068. 2:
  5069. 3:
  5070. /((?>Z)+|A)*/
  5071. ZABCDEFG
  5072. 0: ZA
  5073. 1: A
  5074. /((?>)+|A)*/
  5075. ZABCDEFG
  5076. 0:
  5077. 1:
  5078. /a*/g
  5079. abbab
  5080. 0: a
  5081. 0:
  5082. 0:
  5083. 0: a
  5084. 0:
  5085. 0:
  5086. /[[:space:]]+/
  5087. > \x09\x0a\x0c\x0d\x0b<
  5088. 0: \x09\x0a\x0c\x0d\x0b
  5089. /[[:blank:]]+/
  5090. > \x09\x0a\x0c\x0d\x0b<
  5091. 0: \x09
  5092. /[\s]+/
  5093. > \x09\x0a\x0c\x0d\x0b<
  5094. 0: \x09\x0a\x0c\x0d\x0b
  5095. /\s+/
  5096. > \x09\x0a\x0c\x0d\x0b<
  5097. 0: \x09\x0a\x0c\x0d\x0b
  5098. /a b/x
  5099. ab
  5100. 0: ab
  5101. /(?!\A)x/m
  5102. a\nxb\n
  5103. 0: x
  5104. /(?!^)x/m
  5105. \= Expect no match
  5106. a\nxb\n
  5107. No match
  5108. /abc\Qabc\Eabc/
  5109. abcabcabc
  5110. 0: abcabcabc
  5111. /abc\Q(*+|\Eabc/
  5112. abc(*+|abc
  5113. 0: abc(*+|abc
  5114. / abc\Q abc\Eabc/x
  5115. abc abcabc
  5116. 0: abc abcabc
  5117. \= Expect no match
  5118. abcabcabc
  5119. No match
  5120. /abc#comment
  5121. \Q#not comment
  5122. literal\E/x
  5123. abc#not comment\n literal
  5124. 0: abc#not comment\x0a literal
  5125. /abc#comment
  5126. \Q#not comment
  5127. literal/x
  5128. abc#not comment\n literal
  5129. 0: abc#not comment\x0a literal
  5130. /abc#comment
  5131. \Q#not comment
  5132. literal\E #more comment
  5133. /x
  5134. abc#not comment\n literal
  5135. 0: abc#not comment\x0a literal
  5136. /abc#comment
  5137. \Q#not comment
  5138. literal\E #more comment/x
  5139. abc#not comment\n literal
  5140. 0: abc#not comment\x0a literal
  5141. /\Qabc\$xyz\E/
  5142. abc\\\$xyz
  5143. 0: abc\$xyz
  5144. /\Qabc\E\$\Qxyz\E/
  5145. abc\$xyz
  5146. 0: abc$xyz
  5147. /\Gabc/
  5148. abc
  5149. 0: abc
  5150. \= Expect no match
  5151. xyzabc
  5152. No match
  5153. /\Gabc./g
  5154. abc1abc2xyzabc3
  5155. 0: abc1
  5156. 0: abc2
  5157. /abc./g
  5158. abc1abc2xyzabc3
  5159. 0: abc1
  5160. 0: abc2
  5161. 0: abc3
  5162. /a(?x: b c )d/
  5163. XabcdY
  5164. 0: abcd
  5165. \= Expect no match
  5166. Xa b c d Y
  5167. No match
  5168. /((?x)x y z | a b c)/
  5169. XabcY
  5170. 0: abc
  5171. 1: abc
  5172. AxyzB
  5173. 0: xyz
  5174. 1: xyz
  5175. /(?i)AB(?-i)C/
  5176. XabCY
  5177. 0: abC
  5178. \= Expect no match
  5179. XabcY
  5180. No match
  5181. /((?i)AB(?-i)C|D)E/
  5182. abCE
  5183. 0: abCE
  5184. 1: abC
  5185. DE
  5186. 0: DE
  5187. 1: D
  5188. \= Expect no match
  5189. abcE
  5190. No match
  5191. abCe
  5192. No match
  5193. dE
  5194. No match
  5195. De
  5196. No match
  5197. /(.*)\d+\1/
  5198. abc123abc
  5199. 0: abc123abc
  5200. 1: abc
  5201. abc123bc
  5202. 0: bc123bc
  5203. 1: bc
  5204. /(.*)\d+\1/s
  5205. abc123abc
  5206. 0: abc123abc
  5207. 1: abc
  5208. abc123bc
  5209. 0: bc123bc
  5210. 1: bc
  5211. /((.*))\d+\1/
  5212. abc123abc
  5213. 0: abc123abc
  5214. 1: abc
  5215. 2: abc
  5216. abc123bc
  5217. 0: bc123bc
  5218. 1: bc
  5219. 2: bc
  5220. # This tests for an IPv6 address in the form where it can have up to
  5221. # eight components, one and only one of which is empty. This must be
  5222. # an internal component.
  5223. /^(?!:) # colon disallowed at start
  5224. (?: # start of item
  5225. (?: [0-9a-f]{1,4} | # 1-4 hex digits or
  5226. (?(1)0 | () ) ) # if null previously matched, fail; else null
  5227. : # followed by colon
  5228. ){1,7} # end item; 1-7 of them required
  5229. [0-9a-f]{1,4} $ # final hex number at end of string
  5230. (?(1)|.) # check that there was an empty component
  5231. /ix
  5232. a123::a123
  5233. 0: a123::a123
  5234. 1:
  5235. a123:b342::abcd
  5236. 0: a123:b342::abcd
  5237. 1:
  5238. a123:b342::324e:abcd
  5239. 0: a123:b342::324e:abcd
  5240. 1:
  5241. a123:ddde:b342::324e:abcd
  5242. 0: a123:ddde:b342::324e:abcd
  5243. 1:
  5244. a123:ddde:b342::324e:dcba:abcd
  5245. 0: a123:ddde:b342::324e:dcba:abcd
  5246. 1:
  5247. a123:ddde:9999:b342::324e:dcba:abcd
  5248. 0: a123:ddde:9999:b342::324e:dcba:abcd
  5249. 1:
  5250. \= Expect no match
  5251. 1:2:3:4:5:6:7:8
  5252. No match
  5253. a123:bce:ddde:9999:b342::324e:dcba:abcd
  5254. No match
  5255. a123::9999:b342::324e:dcba:abcd
  5256. No match
  5257. abcde:2:3:4:5:6:7:8
  5258. No match
  5259. ::1
  5260. No match
  5261. abcd:fee0:123::
  5262. No match
  5263. :1
  5264. No match
  5265. 1:
  5266. No match
  5267. /[z\Qa-d]\E]/
  5268. z
  5269. 0: z
  5270. a
  5271. 0: a
  5272. -
  5273. 0: -
  5274. d
  5275. 0: d
  5276. ]
  5277. 0: ]
  5278. \= Expect no match
  5279. b
  5280. No match
  5281. /(a+)*b/
  5282. \= Expect no match
  5283. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  5284. No match
  5285. /(?i)reg(?:ul(?:[aä]|ae)r|ex)/
  5286. REGular
  5287. 0: REGular
  5288. regulaer
  5289. 0: regulaer
  5290. Regex
  5291. 0: Regex
  5292. regulär
  5293. 0: regul\xe4r
  5294. /Åæåä[à-ÿÀ-ß]+/
  5295. Åæåäà
  5296. 0: \xc5\xe6\xe5\xe4\xe0
  5297. Åæåäÿ
  5298. 0: \xc5\xe6\xe5\xe4\xff
  5299. ÅæåäÀ
  5300. 0: \xc5\xe6\xe5\xe4\xc0
  5301. Åæåäß
  5302. 0: \xc5\xe6\xe5\xe4\xdf
  5303. /(?<=Z)X./
  5304. \x84XAZXB
  5305. 0: XB
  5306. /ab cd (?x) de fg/
  5307. ab cd defg
  5308. 0: ab cd defg
  5309. /ab cd(?x) de fg/
  5310. ab cddefg
  5311. 0: ab cddefg
  5312. \= Expect no match
  5313. abcddefg
  5314. No match
  5315. /(?<![^f]oo)(bar)/
  5316. foobarX
  5317. 0: bar
  5318. 1: bar
  5319. \= Expect no match
  5320. boobarX
  5321. No match
  5322. /(?<![^f])X/
  5323. offX
  5324. 0: X
  5325. \= Expect no match
  5326. onyX
  5327. No match
  5328. /(?<=[^f])X/
  5329. onyX
  5330. 0: X
  5331. \= Expect no match
  5332. offX
  5333. No match
  5334. /^/gm
  5335. a\nb\nc\n
  5336. 0:
  5337. 0:
  5338. 0:
  5339. \
  5340. 0:
  5341. /(?<=C\n)^/gm
  5342. A\nC\nC\n
  5343. 0:
  5344. /(?:(?(1)a|b)(X))+/
  5345. bXaX
  5346. 0: bXaX
  5347. 1: X
  5348. /(?:(?(1)\1a|b)(X|Y))+/
  5349. bXXaYYaY
  5350. 0: bXXaYYaY
  5351. 1: Y
  5352. bXYaXXaX
  5353. 0: bX
  5354. 1: X
  5355. /()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
  5356. bXXaYYaY
  5357. 0: bX
  5358. 1:
  5359. 2:
  5360. 3:
  5361. 4:
  5362. 5:
  5363. 6:
  5364. 7:
  5365. 8:
  5366. 9:
  5367. 10: X
  5368. /[[,abc,]+]/
  5369. abc]
  5370. 0: abc]
  5371. a,b]
  5372. 0: a,b]
  5373. [a,b,c]
  5374. 0: [a,b,c]
  5375. /(?-x: )/x
  5376. A\x20B
  5377. 0:
  5378. /(?x)(?-x: \s*#\s*)/
  5379. A # B
  5380. 0: #
  5381. \= Expect no match
  5382. #
  5383. No match
  5384. A s#s B
  5385. No match
  5386. /(?x-is)(?:(?-ixs) \s*#\s*) include/
  5387. A #include
  5388. 0: #include
  5389. \= Expect no match
  5390. A#include
  5391. No match
  5392. A #Include
  5393. No match
  5394. /a*b*\w/
  5395. aaabbbb
  5396. 0: aaabbbb
  5397. aaaa
  5398. 0: aaaa
  5399. a
  5400. 0: a
  5401. /a*b?\w/
  5402. aaabbbb
  5403. 0: aaabb
  5404. aaaa
  5405. 0: aaaa
  5406. a
  5407. 0: a
  5408. /a*b{0,4}\w/
  5409. aaabbbb
  5410. 0: aaabbbb
  5411. aaaa
  5412. 0: aaaa
  5413. a
  5414. 0: a
  5415. /a*b{0,}\w/
  5416. aaabbbb
  5417. 0: aaabbbb
  5418. aaaa
  5419. 0: aaaa
  5420. a
  5421. 0: a
  5422. /a*\d*\w/
  5423. 0a
  5424. 0: 0a
  5425. a
  5426. 0: a
  5427. /a*b *\w/x
  5428. a
  5429. 0: a
  5430. /a*b#comment
  5431. *\w/x
  5432. a
  5433. 0: a
  5434. /a* b *\w/x
  5435. a
  5436. 0: a
  5437. /^\w+=.*(\\\n.*)*/
  5438. abc=xyz\\\npqr
  5439. 0: abc=xyz\
  5440. /(?=(\w+))\1:/
  5441. abcd:
  5442. 0: abcd:
  5443. 1: abcd
  5444. /^(?=(\w+))\1:/
  5445. abcd:
  5446. 0: abcd:
  5447. 1: abcd
  5448. /^\Eabc/
  5449. abc
  5450. 0: abc
  5451. /^[\Eabc]/
  5452. a
  5453. 0: a
  5454. \= Expect no match
  5455. E
  5456. No match
  5457. /^[a-\Ec]/
  5458. b
  5459. 0: b
  5460. \= Expect no match
  5461. -
  5462. No match
  5463. E
  5464. No match
  5465. /^[a\E\E-\Ec]/
  5466. b
  5467. 0: b
  5468. \= Expect no match
  5469. -
  5470. No match
  5471. E
  5472. No match
  5473. /^[\E\Qa\E-\Qz\E]+/
  5474. b
  5475. 0: b
  5476. \= Expect no match
  5477. -
  5478. No match
  5479. /^[a\Q]bc\E]/
  5480. a
  5481. 0: a
  5482. ]
  5483. 0: ]
  5484. c
  5485. 0: c
  5486. /^[a-\Q\E]/
  5487. a
  5488. 0: a
  5489. -
  5490. 0: -
  5491. /^(a()*)*/
  5492. aaaa
  5493. 0: aaaa
  5494. 1: a
  5495. 2:
  5496. /^(?:a(?:(?:))*)*/
  5497. aaaa
  5498. 0: aaaa
  5499. /^(a()+)+/
  5500. aaaa
  5501. 0: aaaa
  5502. 1: a
  5503. 2:
  5504. /^(?:a(?:(?:))+)+/
  5505. aaaa
  5506. 0: aaaa
  5507. /(a){0,3}(?(1)b|(c|))*D/
  5508. abbD
  5509. 0: abbD
  5510. 1: a
  5511. ccccD
  5512. 0: ccccD
  5513. 1: <unset>
  5514. 2:
  5515. D
  5516. 0: D
  5517. 1: <unset>
  5518. 2:
  5519. /(a|)*\d/
  5520. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5521. 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5522. 1:
  5523. \= Expect no match
  5524. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  5525. No match
  5526. /(?>a|)*\d/
  5527. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5528. 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5529. \= Expect no match
  5530. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  5531. No match
  5532. /(?:a|)*\d/
  5533. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5534. 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
  5535. \= Expect no match
  5536. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  5537. No match
  5538. /\Z/g
  5539. abc\n
  5540. 0:
  5541. 0:
  5542. /^(?s)(?>.*)(?<!\n)/
  5543. abc
  5544. 0: abc
  5545. \= Expect no match
  5546. abc\n
  5547. No match
  5548. /^(?![^\n]*\n\z)/
  5549. abc
  5550. 0:
  5551. \= Expect no match
  5552. abc\n
  5553. No match
  5554. /\z(?<!\n)/
  5555. abc
  5556. 0:
  5557. \= Expect no match
  5558. abc\n
  5559. No match
  5560. /(.*(.)?)*/
  5561. abcd
  5562. 0: abcd
  5563. 1:
  5564. /( (A | (?(1)0|) )* )/x
  5565. abcd
  5566. 0:
  5567. 1:
  5568. 2:
  5569. /( ( (?(1)0|) )* )/x
  5570. abcd
  5571. 0:
  5572. 1:
  5573. 2:
  5574. /( (?(1)0|)* )/x
  5575. abcd
  5576. 0:
  5577. 1:
  5578. /[[:abcd:xyz]]/
  5579. a]
  5580. 0: a]
  5581. :]
  5582. 0: :]
  5583. /[abc[:x\]pqr]/
  5584. a
  5585. 0: a
  5586. [
  5587. 0: [
  5588. :
  5589. 0: :
  5590. ]
  5591. 0: ]
  5592. p
  5593. 0: p
  5594. /.*[op][xyz]/
  5595. \= Expect no match
  5596. fooabcfoo
  5597. No match
  5598. /(?(?=.*b)b|^)/
  5599. adc
  5600. 0:
  5601. abc
  5602. 0: b
  5603. /(?(?=^.*b)b|^)/
  5604. adc
  5605. 0:
  5606. \= Expect no match
  5607. abc
  5608. No match
  5609. /(?(?=.*b)b|^)*/
  5610. adc
  5611. 0:
  5612. abc
  5613. 0:
  5614. /(?(?=.*b)b|^)+/
  5615. adc
  5616. 0:
  5617. abc
  5618. 0: b
  5619. /(?(?=b).*b|^d)/
  5620. abc
  5621. 0: b
  5622. /(?(?=.*b).*b|^d)/
  5623. abc
  5624. 0: ab
  5625. /^%((?(?=[a])[^%])|b)*%$/
  5626. %ab%
  5627. 0: %ab%
  5628. 1:
  5629. /(?i)a(?-i)b|c/
  5630. XabX
  5631. 0: ab
  5632. XAbX
  5633. 0: Ab
  5634. CcC
  5635. 0: c
  5636. \= Expect no match
  5637. XABX
  5638. No match
  5639. /[\x00-\xff\s]+/
  5640. \x0a\x0b\x0c\x0d
  5641. 0: \x0a\x0b\x0c\x0d
  5642. /(abc)\1/i
  5643. \= Expect no match
  5644. abc
  5645. No match
  5646. /(abc)\1/
  5647. \= Expect no match
  5648. abc
  5649. No match
  5650. /[^a]*/i
  5651. 12abc
  5652. 0: 12
  5653. 12ABC
  5654. 0: 12
  5655. /[^a]*+/i
  5656. 12abc
  5657. 0: 12
  5658. 12ABC
  5659. 0: 12
  5660. /[^a]*?X/i
  5661. \= Expect no match
  5662. 12abc
  5663. No match
  5664. 12ABC
  5665. No match
  5666. /[^a]+?X/i
  5667. \= Expect no match
  5668. 12abc
  5669. No match
  5670. 12ABC
  5671. No match
  5672. /[^a]?X/i
  5673. 12aXbcX
  5674. 0: X
  5675. 12AXBCX
  5676. 0: X
  5677. BCX
  5678. 0: CX
  5679. /[^a]??X/i
  5680. 12aXbcX
  5681. 0: X
  5682. 12AXBCX
  5683. 0: X
  5684. BCX
  5685. 0: CX
  5686. /[^a]?+X/i
  5687. 12aXbcX
  5688. 0: cX
  5689. 12AXBCX
  5690. 0: CX
  5691. BCX
  5692. 0: CX
  5693. /[^a]{2,3}/i
  5694. abcdef
  5695. 0: bcd
  5696. ABCDEF
  5697. 0: BCD
  5698. /[^a]{2,3}?/i
  5699. abcdef
  5700. 0: bc
  5701. ABCDEF
  5702. 0: BC
  5703. /[^a]{2,3}+/i
  5704. abcdef
  5705. 0: bcd
  5706. ABCDEF
  5707. 0: BCD
  5708. /((a|)+)+Z/
  5709. Z
  5710. 0: Z
  5711. 1:
  5712. 2:
  5713. /(a)b|(a)c/
  5714. ac
  5715. 0: ac
  5716. 1: <unset>
  5717. 2: a
  5718. /(?>(a))b|(a)c/
  5719. ac
  5720. 0: ac
  5721. 1: <unset>
  5722. 2: a
  5723. /(?=(a))ab|(a)c/
  5724. ac
  5725. 0: ac
  5726. 1: <unset>
  5727. 2: a
  5728. /((?>(a))b|(a)c)/
  5729. ac
  5730. 0: ac
  5731. 1: ac
  5732. 2: <unset>
  5733. 3: a
  5734. /((?>(a))b|(a)c)++/
  5735. ac
  5736. 0: ac
  5737. 1: ac
  5738. 2: <unset>
  5739. 3: a
  5740. /(?:(?>(a))b|(a)c)++/
  5741. ac
  5742. 0: ac
  5743. 1: <unset>
  5744. 2: a
  5745. /(?=(?>(a))b|(a)c)(..)/
  5746. ac
  5747. 0: ac
  5748. 1: <unset>
  5749. 2: a
  5750. 3: ac
  5751. /(?>(?>(a))b|(a)c)/
  5752. ac
  5753. 0: ac
  5754. 1: <unset>
  5755. 2: a
  5756. /(?:(?>([ab])))+a=/aftertext
  5757. =ba=
  5758. 0: ba=
  5759. 0+
  5760. 1: b
  5761. /(?>([ab]))+a=/aftertext
  5762. =ba=
  5763. 0: ba=
  5764. 0+
  5765. 1: b
  5766. /((?>(a+)b)+(aabab))/
  5767. aaaabaaabaabab
  5768. 0: aaaabaaabaabab
  5769. 1: aaaabaaabaabab
  5770. 2: aaa
  5771. 3: aabab
  5772. /(?>a+|ab)+?c/
  5773. \= Expect no match
  5774. aabc
  5775. No match
  5776. /(?>a+|ab)+c/
  5777. \= Expect no match
  5778. aabc
  5779. No match
  5780. /(?:a+|ab)+c/
  5781. aabc
  5782. 0: aabc
  5783. /(?(?=(a))a)/
  5784. a
  5785. 0: a
  5786. 1: a
  5787. /(?(?=(a))a)(b)/
  5788. ab
  5789. 0: ab
  5790. 1: a
  5791. 2: b
  5792. /^(?:a|ab)++c/
  5793. \= Expect no match
  5794. aaaabc
  5795. No match
  5796. /^(?>a|ab)++c/
  5797. \= Expect no match
  5798. aaaabc
  5799. No match
  5800. /^(?:a|ab)+c/
  5801. aaaabc
  5802. 0: aaaabc
  5803. /(?=abc){3}abc/aftertext
  5804. abcabcabc
  5805. 0: abc
  5806. 0+ abcabc
  5807. \= Expect no match
  5808. xyz
  5809. No match
  5810. /(?=abc)+abc/aftertext
  5811. abcabcabc
  5812. 0: abc
  5813. 0+ abcabc
  5814. \= Expect no match
  5815. xyz
  5816. No match
  5817. /(?=abc)++abc/aftertext
  5818. abcabcabc
  5819. 0: abc
  5820. 0+ abcabc
  5821. \= Expect no match
  5822. xyz
  5823. No match
  5824. /(?=abc){0}xyz/
  5825. xyz
  5826. 0: xyz
  5827. /(?=abc){1}xyz/
  5828. \= Expect no match
  5829. xyz
  5830. No match
  5831. /(?=(a))?./
  5832. ab
  5833. 0: a
  5834. 1: a
  5835. bc
  5836. 0: b
  5837. /(?=(a))??./
  5838. ab
  5839. 0: a
  5840. bc
  5841. 0: b
  5842. /^(?=(?1))?[az]([abc])d/
  5843. abd
  5844. 0: abd
  5845. 1: b
  5846. zcdxx
  5847. 0: zcd
  5848. 1: c
  5849. /^(?!a){0}\w+/
  5850. aaaaa
  5851. 0: aaaaa
  5852. /(?<=(abc))?xyz/
  5853. abcxyz
  5854. 0: xyz
  5855. 1: abc
  5856. pqrxyz
  5857. 0: xyz
  5858. /^[\g<a>]+/
  5859. ggg<<<aaa>>>
  5860. 0: ggg<<<aaa>>>
  5861. \= Expect no match
  5862. \\ga
  5863. No match
  5864. /^[\ga]+/
  5865. gggagagaxyz
  5866. 0: gggagaga
  5867. /^[:a[:digit:]]+/
  5868. aaaa444:::Z
  5869. 0: aaaa444:::
  5870. /^[:a[:digit:]:b]+/
  5871. aaaa444:::bbbZ
  5872. 0: aaaa444:::bbb
  5873. /[:a]xxx[b:]/
  5874. :xxx:
  5875. 0: :xxx:
  5876. /(?<=a{2})b/i
  5877. xaabc
  5878. 0: b
  5879. \= Expect no match
  5880. xabc
  5881. No match
  5882. /(?<!a{2})b/i
  5883. xabc
  5884. 0: b
  5885. \= Expect no match
  5886. xaabc
  5887. No match
  5888. /(?<=a\h)c/
  5889. xa c
  5890. 0: c
  5891. /(?<=[^a]{2})b/
  5892. axxbc
  5893. 0: b
  5894. aAAbc
  5895. 0: b
  5896. \= Expect no match
  5897. xaabc
  5898. No match
  5899. /(?<=[^a]{2})b/i
  5900. axxbc
  5901. 0: b
  5902. \= Expect no match
  5903. aAAbc
  5904. No match
  5905. xaabc
  5906. No match
  5907. /(?<=a\H)c/
  5908. abc
  5909. 0: c
  5910. /(?<=a\V)c/
  5911. abc
  5912. 0: c
  5913. /(?<=a\v)c/
  5914. a\nc
  5915. 0: c
  5916. /(?(?=c)c|d)++Y/
  5917. XcccddYX
  5918. 0: cccddY
  5919. /(?(?=c)c|d)*+Y/
  5920. XcccddYX
  5921. 0: cccddY
  5922. /^(a{2,3}){2,}+a/
  5923. aaaaaaa
  5924. 0: aaaaaaa
  5925. 1: aaa
  5926. \= Expect no match
  5927. aaaaaa
  5928. No match
  5929. aaaaaaaaa
  5930. No match
  5931. /^(a{2,3})++a/
  5932. \= Expect no match
  5933. aaaaaa
  5934. No match
  5935. /^(a{2,3})*+a/
  5936. \= Expect no match
  5937. aaaaaa
  5938. No match
  5939. /\H\h\V\v/
  5940. X X\x0a
  5941. 0: X X\x0a
  5942. X\x09X\x0b
  5943. 0: X\x09X\x0b
  5944. \= Expect no match
  5945. \xa0 X\x0a
  5946. No match
  5947. /\H*\h+\V?\v{3,4}/
  5948. \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
  5949. 0: \x09 \xa0X\x0a\x0b\x0c\x0d
  5950. \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
  5951. 0: \x09 \xa0\x0a\x0b\x0c\x0d
  5952. \x09\x20\xa0\x0a\x0b\x0c
  5953. 0: \x09 \xa0\x0a\x0b\x0c
  5954. \= Expect no match
  5955. \x09\x20\xa0\x0a\x0b
  5956. No match
  5957. /\H{3,4}/
  5958. XY ABCDE
  5959. 0: ABCD
  5960. XY PQR ST
  5961. 0: PQR
  5962. /.\h{3,4}./
  5963. XY AB PQRS
  5964. 0: B P
  5965. /\h*X\h?\H+Y\H?Z/
  5966. >XNNNYZ
  5967. 0: XNNNYZ
  5968. > X NYQZ
  5969. 0: X NYQZ
  5970. \= Expect no match
  5971. >XYZ
  5972. No match
  5973. > X NY Z
  5974. No match
  5975. /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
  5976. >XY\x0aZ\x0aA\x0bNN\x0c
  5977. 0: XY\x0aZ\x0aA\x0bNN\x0c
  5978. >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
  5979. 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
  5980. /(foo)\Kbar/
  5981. foobar
  5982. 0: bar
  5983. 1: foo
  5984. /(foo)(\Kbar|baz)/
  5985. foobar
  5986. 0: bar
  5987. 1: foo
  5988. 2: bar
  5989. foobaz
  5990. 0: foobaz
  5991. 1: foo
  5992. 2: baz
  5993. /(foo\Kbar)baz/
  5994. foobarbaz
  5995. 0: barbaz
  5996. 1: foobar
  5997. /abc\K|def\K/g,aftertext
  5998. Xabcdefghi
  5999. 0:
  6000. 0+ defghi
  6001. 0:
  6002. 0+ ghi
  6003. /ab\Kc|de\Kf/g,aftertext
  6004. Xabcdefghi
  6005. 0: c
  6006. 0+ defghi
  6007. 0: f
  6008. 0+ ghi
  6009. /(?=C)/g,aftertext
  6010. ABCDECBA
  6011. 0:
  6012. 0+ CDECBA
  6013. 0:
  6014. 0+ CBA
  6015. /^abc\K/aftertext
  6016. abcdef
  6017. 0:
  6018. 0+ def
  6019. \= Expect no match
  6020. defabcxyz
  6021. No match
  6022. /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/
  6023. ababababbbabZXXXX
  6024. 0: ababababbbabZ
  6025. 1: ab
  6026. 2: b
  6027. /(?<A>tom|bon)-\g{A}/
  6028. tom-tom
  6029. 0: tom-tom
  6030. 1: tom
  6031. bon-bon
  6032. 0: bon-bon
  6033. 1: bon
  6034. /(^(a|b\g{-1}))/
  6035. \= Expect no match
  6036. bacxxx
  6037. No match
  6038. /(?|(abc)|(xyz))\1/
  6039. abcabc
  6040. 0: abcabc
  6041. 1: abc
  6042. xyzxyz
  6043. 0: xyzxyz
  6044. 1: xyz
  6045. \= Expect no match
  6046. abcxyz
  6047. No match
  6048. xyzabc
  6049. No match
  6050. /(?|(abc)|(xyz))(?1)/
  6051. abcabc
  6052. 0: abcabc
  6053. 1: abc
  6054. xyzabc
  6055. 0: xyzabc
  6056. 1: xyz
  6057. \= Expect no match
  6058. xyzxyz
  6059. No match
  6060. /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
  6061. XYabcdY
  6062. 0: XYabcdY
  6063. 1: a
  6064. 2: b
  6065. 3: c
  6066. 4: d
  6067. 5: Y
  6068. /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
  6069. XYabcdY
  6070. 0: XYabcdY
  6071. 1: a
  6072. 2: b
  6073. 3: <unset>
  6074. 4: <unset>
  6075. 5: c
  6076. 6: d
  6077. 7: Y
  6078. /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
  6079. XYabcdY
  6080. 0: XYabcdY
  6081. 1: a
  6082. 2: b
  6083. 3: <unset>
  6084. 4: <unset>
  6085. 5: c
  6086. 6: d
  6087. 7: Y
  6088. /(?'abc'\w+):\k<abc>{2}/
  6089. a:aaxyz
  6090. 0: a:aa
  6091. 1: a
  6092. ab:ababxyz
  6093. 0: ab:abab
  6094. 1: ab
  6095. \= Expect no match
  6096. a:axyz
  6097. No match
  6098. ab:abxyz
  6099. No match
  6100. /(?'abc'\w+):\g{abc}{2}/
  6101. a:aaxyz
  6102. 0: a:aa
  6103. 1: a
  6104. ab:ababxyz
  6105. 0: ab:abab
  6106. 1: ab
  6107. \= Expect no match
  6108. a:axyz
  6109. No match
  6110. ab:abxyz
  6111. No match
  6112. /^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
  6113. abd
  6114. 0: abd
  6115. 1: a
  6116. ce
  6117. 0: ce
  6118. /^(a.)\g-1Z/
  6119. aXaXZ
  6120. 0: aXaXZ
  6121. 1: aX
  6122. /^(a.)\g{-1}Z/
  6123. aXaXZ
  6124. 0: aXaXZ
  6125. 1: aX
  6126. /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
  6127. abcd
  6128. 0: ab
  6129. /(?<all>(?:(?:a(?&all))|(b))(c?))/
  6130. aabc
  6131. 0: aabc
  6132. 1: aabc
  6133. 2: <unset>
  6134. 3:
  6135. /(a(b)|(c))(?1)/
  6136. abc
  6137. 0: abc
  6138. 1: ab
  6139. 2: b
  6140. cab
  6141. 0: cab
  6142. 1: c
  6143. 2: <unset>
  6144. 3: c
  6145. /(?1)(a(b)|(c))/
  6146. abc
  6147. 0: abc
  6148. 1: c
  6149. 2: <unset>
  6150. 3: c
  6151. cab
  6152. 0: cab
  6153. 1: ab
  6154. 2: b
  6155. /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
  6156. (?(DEFINE)
  6157. (?<NAME_PAT>[a-z]+)
  6158. (?<ADDRESS_PAT>\d+)
  6159. )/x
  6160. metcalfe 33
  6161. 0: metcalfe 33
  6162. 1: metcalfe
  6163. 2: 33
  6164. /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  6165. 1.2.3.4
  6166. 0: 1.2.3.4
  6167. 1: <unset>
  6168. 2: .4
  6169. 131.111.10.206
  6170. 0: 131.111.10.206
  6171. 1: <unset>
  6172. 2: .206
  6173. 10.0.0.0
  6174. 0: 10.0.0.0
  6175. 1: <unset>
  6176. 2: .0
  6177. \= Expect no match
  6178. 10.6
  6179. No match
  6180. 455.3.4.5
  6181. No match
  6182. /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  6183. 1.2.3.4
  6184. 0: 1.2.3.4
  6185. 1: .4
  6186. 131.111.10.206
  6187. 0: 131.111.10.206
  6188. 1: .206
  6189. 10.0.0.0
  6190. 0: 10.0.0.0
  6191. 1: .0
  6192. \= Expect no match
  6193. 10.6
  6194. No match
  6195. 455.3.4.5
  6196. No match
  6197. /^(\w++|\s++)*$/
  6198. now is the time for all good men to come to the aid of the party
  6199. 0: now is the time for all good men to come to the aid of the party
  6200. 1: party
  6201. \= Expect no match
  6202. this is not a line with only words and spaces!
  6203. No match
  6204. /(\d++)(\w)/
  6205. 12345a
  6206. 0: 12345a
  6207. 1: 12345
  6208. 2: a
  6209. \= Expect no match
  6210. 12345+
  6211. No match
  6212. /a++b/
  6213. aaab
  6214. 0: aaab
  6215. /(a++b)/
  6216. aaab
  6217. 0: aaab
  6218. 1: aaab
  6219. /(a++)b/
  6220. aaab
  6221. 0: aaab
  6222. 1: aaa
  6223. /([^()]++|\([^()]*\))+/
  6224. ((abc(ade)ufh()()x
  6225. 0: abc(ade)ufh()()x
  6226. 1: x
  6227. /\(([^()]++|\([^()]+\))+\)/
  6228. (abc)
  6229. 0: (abc)
  6230. 1: abc
  6231. (abc(def)xyz)
  6232. 0: (abc(def)xyz)
  6233. 1: xyz
  6234. \= Expect no match
  6235. ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  6236. No match
  6237. /^([^()]|\((?1)*\))*$/
  6238. abc
  6239. 0: abc
  6240. 1: c
  6241. a(b)c
  6242. 0: a(b)c
  6243. 1: c
  6244. a(b(c))d
  6245. 0: a(b(c))d
  6246. 1: d
  6247. \= Expect no match)
  6248. a(b(c)d
  6249. No match
  6250. /^>abc>([^()]|\((?1)*\))*<xyz<$/
  6251. >abc>123<xyz<
  6252. 0: >abc>123<xyz<
  6253. 1: 3
  6254. >abc>1(2)3<xyz<
  6255. 0: >abc>1(2)3<xyz<
  6256. 1: 3
  6257. >abc>(1(2)3)<xyz<
  6258. 0: >abc>(1(2)3)<xyz<
  6259. 1: (1(2)3)
  6260. /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
  6261. 1221
  6262. 0: 1221
  6263. 1: 1221
  6264. 2: 1
  6265. Satanoscillatemymetallicsonatas
  6266. 0: Satanoscillatemymetallicsonatas
  6267. 1: <unset>
  6268. 2: <unset>
  6269. 3: Satanoscillatemymetallicsonatas
  6270. 4: S
  6271. AmanaplanacanalPanama
  6272. 0: AmanaplanacanalPanama
  6273. 1: <unset>
  6274. 2: <unset>
  6275. 3: AmanaplanacanalPanama
  6276. 4: A
  6277. AblewasIereIsawElba
  6278. 0: AblewasIereIsawElba
  6279. 1: <unset>
  6280. 2: <unset>
  6281. 3: AblewasIereIsawElba
  6282. 4: A
  6283. \= Expect no match
  6284. Thequickbrownfox
  6285. No match
  6286. /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
  6287. 12
  6288. 0: 12
  6289. 1: 12
  6290. (((2+2)*-3)-7)
  6291. 0: (((2+2)*-3)-7)
  6292. 1: (((2+2)*-3)-7)
  6293. 2: -
  6294. -12
  6295. 0: -12
  6296. 1: -12
  6297. \= Expect no match
  6298. ((2+2)*-3)-7)
  6299. No match
  6300. /^(x(y|(?1){2})z)/
  6301. xyz
  6302. 0: xyz
  6303. 1: xyz
  6304. 2: y
  6305. xxyzxyzz
  6306. 0: xxyzxyzz
  6307. 1: xxyzxyzz
  6308. 2: xyzxyz
  6309. \= Expect no match
  6310. xxyzz
  6311. No match
  6312. xxyzxyzxyzz
  6313. No match
  6314. /((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
  6315. <>
  6316. 0: <>
  6317. 1: <>
  6318. 2: <>
  6319. <abcd>
  6320. 0: <abcd>
  6321. 1: <abcd>
  6322. 2: <abcd>
  6323. <abc <123> hij>
  6324. 0: <abc <123> hij>
  6325. 1: <abc <123> hij>
  6326. 2: <abc <123> hij>
  6327. <abc <def> hij>
  6328. 0: <def>
  6329. 1: <def>
  6330. 2: <def>
  6331. <abc<>def>
  6332. 0: <abc<>def>
  6333. 1: <abc<>def>
  6334. 2: <abc<>def>
  6335. <abc<>
  6336. 0: <>
  6337. 1: <>
  6338. 2: <>
  6339. \= Expect no match
  6340. <abc
  6341. No match
  6342. /^a+(*FAIL)/
  6343. \= Expect no match
  6344. aaaaaa
  6345. No match
  6346. /a+b?c+(*FAIL)/
  6347. \= Expect no match
  6348. aaabccc
  6349. No match
  6350. /a+b?(*PRUNE)c+(*FAIL)/
  6351. \= Expect no match
  6352. aaabccc
  6353. No match
  6354. /a+b?(*COMMIT)c+(*FAIL)/
  6355. \= Expect no match
  6356. aaabccc
  6357. No match
  6358. /a+b?(*SKIP)c+(*FAIL)/
  6359. \= Expect no match
  6360. aaabcccaaabccc
  6361. No match
  6362. /^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  6363. aaaxxxxxx
  6364. 0: aaaxxxxxx
  6365. aaa++++++
  6366. 0: aaa
  6367. bbbxxxxx
  6368. 0: bbbxxxxx
  6369. bbb+++++
  6370. 0: bbb
  6371. cccxxxx
  6372. 0: cccxxxx
  6373. ccc++++
  6374. 0: ccc
  6375. dddddddd
  6376. 0: ddd
  6377. /^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
  6378. aaaxxxxxx
  6379. 0: aaaxxxxxx
  6380. 1: aaaxxxxxx
  6381. aaa++++++
  6382. 0: aaa
  6383. 1: aaa
  6384. bbbxxxxx
  6385. 0: bbbxxxxx
  6386. 1: bbbxxxxx
  6387. bbb+++++
  6388. 0: bbb
  6389. 1: bbb
  6390. cccxxxx
  6391. 0: cccxxxx
  6392. 1: cccxxxx
  6393. ccc++++
  6394. 0: ccc
  6395. 1: ccc
  6396. dddddddd
  6397. 0: ddd
  6398. 1: ddd
  6399. /a+b?(*THEN)c+(*FAIL)/
  6400. \= Expect no match
  6401. aaabccc
  6402. No match
  6403. /(A (A|B(*ACCEPT)|C) D)(E)/x
  6404. AB
  6405. 0: AB
  6406. 1: AB
  6407. 2: B
  6408. ABX
  6409. 0: AB
  6410. 1: AB
  6411. 2: B
  6412. AADE
  6413. 0: AADE
  6414. 1: AAD
  6415. 2: A
  6416. 3: E
  6417. ACDE
  6418. 0: ACDE
  6419. 1: ACD
  6420. 2: C
  6421. 3: E
  6422. \= Expect no match
  6423. AD
  6424. No match
  6425. /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  6426. 1221
  6427. 0: 1221
  6428. 1: 1221
  6429. 2: 1
  6430. Satan, oscillate my metallic sonatas!
  6431. 0: Satan, oscillate my metallic sonatas!
  6432. 1: <unset>
  6433. 2: <unset>
  6434. 3: Satan, oscillate my metallic sonatas
  6435. 4: S
  6436. A man, a plan, a canal: Panama!
  6437. 0: A man, a plan, a canal: Panama!
  6438. 1: <unset>
  6439. 2: <unset>
  6440. 3: A man, a plan, a canal: Panama
  6441. 4: A
  6442. Able was I ere I saw Elba.
  6443. 0: Able was I ere I saw Elba.
  6444. 1: <unset>
  6445. 2: <unset>
  6446. 3: Able was I ere I saw Elba
  6447. 4: A
  6448. \= Expect no match
  6449. The quick brown fox
  6450. No match
  6451. /^((.)(?1)\2|.)$/
  6452. a
  6453. 0: a
  6454. 1: a
  6455. aba
  6456. 0: aba
  6457. 1: aba
  6458. 2: a
  6459. aabaa
  6460. 0: aabaa
  6461. 1: aabaa
  6462. 2: a
  6463. abcdcba
  6464. 0: abcdcba
  6465. 1: abcdcba
  6466. 2: a
  6467. pqaabaaqp
  6468. 0: pqaabaaqp
  6469. 1: pqaabaaqp
  6470. 2: p
  6471. ablewasiereisawelba
  6472. 0: ablewasiereisawelba
  6473. 1: ablewasiereisawelba
  6474. 2: a
  6475. \= Expect no match
  6476. rhubarb
  6477. No match
  6478. the quick brown fox
  6479. No match
  6480. /(a)(?<=b(?1))/
  6481. baz
  6482. 0: a
  6483. 1: a
  6484. \= Expect no match
  6485. caz
  6486. No match
  6487. /(?<=b(?1))(a)/
  6488. zbaaz
  6489. 0: a
  6490. 1: a
  6491. \= Expect no match
  6492. aaa
  6493. No match
  6494. /(?<X>a)(?<=b(?&X))/
  6495. baz
  6496. 0: a
  6497. 1: a
  6498. /^(?|(abc)|(def))\1/
  6499. abcabc
  6500. 0: abcabc
  6501. 1: abc
  6502. defdef
  6503. 0: defdef
  6504. 1: def
  6505. \= Expect no match
  6506. abcdef
  6507. No match
  6508. defabc
  6509. No match
  6510. /^(?|(abc)|(def))(?1)/
  6511. abcabc
  6512. 0: abcabc
  6513. 1: abc
  6514. defabc
  6515. 0: defabc
  6516. 1: def
  6517. \= Expect no match
  6518. defdef
  6519. No match
  6520. abcdef
  6521. No match
  6522. /(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames
  6523. a\"aaaaa
  6524. 0: a"aaaaa
  6525. 1: "
  6526. 2: <unset>
  6527. 3: "
  6528. b\"aaaaa
  6529. 0: b"aaaaa
  6530. 1: <unset>
  6531. 2: <unset>
  6532. 3: <unset>
  6533. 4: "
  6534. 5: <unset>
  6535. 6: "
  6536. \= Expect no match
  6537. b\"11111
  6538. No match
  6539. /(?:(?1)|B)(A(*F)|C)/
  6540. ABCD
  6541. 0: BC
  6542. 1: C
  6543. CCD
  6544. 0: CC
  6545. 1: C
  6546. \= Expect no match
  6547. CAD
  6548. No match
  6549. /^(?:(?1)|B)(A(*F)|C)/
  6550. CCD
  6551. 0: CC
  6552. 1: C
  6553. BCD
  6554. 0: BC
  6555. 1: C
  6556. \= Expect no match
  6557. ABCD
  6558. No match
  6559. CAD
  6560. No match
  6561. BAD
  6562. No match
  6563. /(?:(?1)|B)(A(*ACCEPT)XX|C)D/
  6564. AAD
  6565. 0: AA
  6566. 1: A
  6567. ACD
  6568. 0: ACD
  6569. 1: C
  6570. BAD
  6571. 0: BA
  6572. 1: A
  6573. BCD
  6574. 0: BCD
  6575. 1: C
  6576. BAX
  6577. 0: BA
  6578. 1: A
  6579. \= Expect no match
  6580. ACX
  6581. No match
  6582. ABC
  6583. No match
  6584. /(?(DEFINE)(A))B(?1)C/
  6585. BAC
  6586. 0: BAC
  6587. /(?(DEFINE)((A)\2))B(?1)C/
  6588. BAAC
  6589. 0: BAAC
  6590. /(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
  6591. (ab(cd)ef)
  6592. 0: (ab(cd)ef)
  6593. 1: (ab(cd)ef)
  6594. 2: ef
  6595. /^(?=a(*SKIP)b|ac)/
  6596. \= Expect no match
  6597. ac
  6598. No match
  6599. /^(?=a(*PRUNE)b)/
  6600. ab
  6601. 0:
  6602. \= Expect no match
  6603. ac
  6604. No match
  6605. /^(?=a(*ACCEPT)b)/
  6606. ac
  6607. 0:
  6608. /(?>a\Kb)/
  6609. ab
  6610. 0: b
  6611. /((?>a\Kb))/
  6612. ab
  6613. 0: b
  6614. 1: ab
  6615. /(a\Kb)/
  6616. ab
  6617. 0: b
  6618. 1: ab
  6619. /^a\Kcz|ac/
  6620. ac
  6621. 0: ac
  6622. /(?>a\Kbz|ab)/
  6623. ab
  6624. 0: ab
  6625. /^(?&t)(?(DEFINE)(?<t>a\Kb))$/
  6626. ab
  6627. 0: b
  6628. /^([^()]|\((?1)*\))*$/
  6629. a(b)c
  6630. 0: a(b)c
  6631. 1: c
  6632. a(b(c)d)e
  6633. 0: a(b(c)d)e
  6634. 1: e
  6635. /(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
  6636. 0
  6637. 0: 0
  6638. 1: 0
  6639. 00
  6640. 0: 00
  6641. 1: 00
  6642. 2: 0
  6643. 0000
  6644. 0: 0000
  6645. 1: 0000
  6646. 2: 0
  6647. /(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
  6648. 0
  6649. 0: 0
  6650. 1: 0
  6651. 2: 0
  6652. 00
  6653. 0: 0
  6654. 1: 0
  6655. 2: 0
  6656. 0000
  6657. 0: 0
  6658. 1: 0
  6659. 2: 0
  6660. # This one does fail, as expected, in Perl. It needs the complex item at the
  6661. # end of the pattern. A single letter instead of (B|D) makes it not fail, which
  6662. # I think is a Perl bug.
  6663. /A(*COMMIT)(B|D)/
  6664. \= Expect no match
  6665. ACABX
  6666. No match
  6667. # Check the use of names for failure
  6668. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  6669. \= Expect no match
  6670. AC
  6671. No match, mark = A
  6672. CB
  6673. No match, mark = B
  6674. /(*MARK:A)(*SKIP:B)(C|X)/mark
  6675. C
  6676. 0: C
  6677. 1: C
  6678. MK: A
  6679. \= Expect no match
  6680. D
  6681. No match, mark = A
  6682. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  6683. \= Expect no match
  6684. CB
  6685. No match, mark = B
  6686. /^(?:A(*THEN:A)B|C(*THEN:B)D)/mark
  6687. \= Expect no match
  6688. CB
  6689. No match, mark = B
  6690. /^(?>A(*THEN:A)B|C(*THEN:B)D)/mark
  6691. \= Expect no match
  6692. CB
  6693. No match, mark = B
  6694. # This should succeed, as the skip causes bump to offset 1 (the mark). Note
  6695. # that we have to have something complicated such as (B|Z) at the end because,
  6696. # for Perl, a simple character somehow causes an unwanted optimization to mess
  6697. # with the handling of backtracking verbs.
  6698. /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  6699. AAAC
  6700. 0: AC
  6701. # Test skipping over a non-matching mark.
  6702. /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/x,mark
  6703. AAAC
  6704. 0: AC
  6705. # Check shorthand for MARK.
  6706. /A(*:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  6707. AAAC
  6708. 0: AC
  6709. /(*:A)A+(*SKIP:A)(B|Z)/mark
  6710. \= Expect no match
  6711. AAAC
  6712. No match, mark = A
  6713. # This should succeed, as a non-existent skip name disables the skip.
  6714. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  6715. AAAC
  6716. 0: AC
  6717. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/x,mark
  6718. AAAC
  6719. 0: AC
  6720. MK: B
  6721. # COMMIT at the start of a pattern should act like an anchor. Again, however,
  6722. # we need the complication for Perl.
  6723. /(*COMMIT)(A|P)(B|P)(C|P)/
  6724. ABCDEFG
  6725. 0: ABC
  6726. 1: A
  6727. 2: B
  6728. 3: C
  6729. \= Expect no match
  6730. DEFGABC
  6731. No match
  6732. # COMMIT inside an atomic group can't stop backtracking over the group.
  6733. /(\w+)(?>b(*COMMIT))\w{2}/
  6734. abbb
  6735. 0: abbb
  6736. 1: a
  6737. /(\w+)b(*COMMIT)\w{2}/
  6738. \= Expect no match
  6739. abbb
  6740. No match
  6741. # Check opening parens in comment when seeking forward reference.
  6742. /(?&t)(?#()(?(DEFINE)(?<t>a))/
  6743. bac
  6744. 0: a
  6745. # COMMIT should override THEN.
  6746. /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
  6747. \= Expect no match
  6748. yes
  6749. No match
  6750. /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
  6751. \= Expect no match
  6752. yes
  6753. No match
  6754. /b?(*SKIP)c/
  6755. bc
  6756. 0: bc
  6757. abc
  6758. 0: bc
  6759. /(*SKIP)bc/
  6760. \= Expect no match
  6761. a
  6762. No match
  6763. /(*SKIP)b/
  6764. \= Expect no match
  6765. a
  6766. No match
  6767. /(?P<abn>(?P=abn)xxx|)+/
  6768. xxx
  6769. 0:
  6770. 1:
  6771. /(?i:([^b]))(?1)/
  6772. aa
  6773. 0: aa
  6774. 1: a
  6775. aA
  6776. 0: aA
  6777. 1: a
  6778. \= Expect no match
  6779. ab
  6780. No match
  6781. aB
  6782. No match
  6783. Ba
  6784. No match
  6785. ba
  6786. No match
  6787. /^(?&t)*+(?(DEFINE)(?<t>a))\w$/
  6788. aaaaaaX
  6789. 0: aaaaaaX
  6790. \= Expect no match
  6791. aaaaaa
  6792. No match
  6793. /^(?&t)*(?(DEFINE)(?<t>a))\w$/
  6794. aaaaaaX
  6795. 0: aaaaaaX
  6796. aaaaaa
  6797. 0: aaaaaa
  6798. /^(a)*+(\w)/
  6799. aaaaX
  6800. 0: aaaaX
  6801. 1: a
  6802. 2: X
  6803. YZ
  6804. 0: Y
  6805. 1: <unset>
  6806. 2: Y
  6807. \= Expect no match
  6808. aaaa
  6809. No match
  6810. /^(?:a)*+(\w)/
  6811. aaaaX
  6812. 0: aaaaX
  6813. 1: X
  6814. YZ
  6815. 0: Y
  6816. 1: Y
  6817. \= Expect no match
  6818. aaaa
  6819. No match
  6820. /^(a)++(\w)/
  6821. aaaaX
  6822. 0: aaaaX
  6823. 1: a
  6824. 2: X
  6825. \= Expect no match
  6826. aaaa
  6827. No match
  6828. YZ
  6829. No match
  6830. /^(?:a)++(\w)/
  6831. aaaaX
  6832. 0: aaaaX
  6833. 1: X
  6834. \= Expect no match
  6835. aaaa
  6836. No match
  6837. YZ
  6838. No match
  6839. /^(a)?+(\w)/
  6840. aaaaX
  6841. 0: aa
  6842. 1: a
  6843. 2: a
  6844. YZ
  6845. 0: Y
  6846. 1: <unset>
  6847. 2: Y
  6848. /^(?:a)?+(\w)/
  6849. aaaaX
  6850. 0: aa
  6851. 1: a
  6852. YZ
  6853. 0: Y
  6854. 1: Y
  6855. /^(a){2,}+(\w)/
  6856. aaaaX
  6857. 0: aaaaX
  6858. 1: a
  6859. 2: X
  6860. \= Expect no match
  6861. aaa
  6862. No match
  6863. YZ
  6864. No match
  6865. /^(?:a){2,}+(\w)/
  6866. aaaaX
  6867. 0: aaaaX
  6868. 1: X
  6869. \= Expect no match
  6870. aaa
  6871. No match
  6872. YZ
  6873. No match
  6874. /(a|)*(?1)b/
  6875. b
  6876. 0: b
  6877. 1:
  6878. ab
  6879. 0: ab
  6880. 1:
  6881. aab
  6882. 0: aab
  6883. 1:
  6884. /(a)++(?1)b/
  6885. \= Expect no match
  6886. ab
  6887. No match
  6888. aab
  6889. No match
  6890. /(a)*+(?1)b/
  6891. \= Expect no match
  6892. ab
  6893. No match
  6894. aab
  6895. No match
  6896. /(?1)(?:(b)){0}/
  6897. b
  6898. 0: b
  6899. /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
  6900. foo(bar(baz)+baz(bop))
  6901. 0: foo(bar(baz)+baz(bop))
  6902. 1: foo(bar(baz)+baz(bop))
  6903. 2: (bar(baz)+baz(bop))
  6904. 3: bar(baz)+baz(bop)
  6905. /(A (A|B(*ACCEPT)|C) D)(E)/x
  6906. AB
  6907. 0: AB
  6908. 1: AB
  6909. 2: B
  6910. /\A.*?(a|bc)/
  6911. ba
  6912. 0: ba
  6913. 1: a
  6914. /\A.*?(?:a|bc)++/
  6915. ba
  6916. 0: ba
  6917. /\A.*?(a|bc)++/
  6918. ba
  6919. 0: ba
  6920. 1: a
  6921. /\A.*?(?:a|bc|d)/
  6922. ba
  6923. 0: ba
  6924. /(?:(b))++/
  6925. beetle
  6926. 0: b
  6927. 1: b
  6928. /(?(?=(a(*ACCEPT)z))a)/
  6929. a
  6930. 0: a
  6931. 1: a
  6932. /^(a)(?1)+ab/
  6933. aaaab
  6934. 0: aaaab
  6935. 1: a
  6936. /^(a)(?1)++ab/
  6937. \= Expect no match
  6938. aaaab
  6939. No match
  6940. /^(?=a(*:M))aZ/mark
  6941. aZbc
  6942. 0: aZ
  6943. MK: M
  6944. /^(?!(*:M)b)aZ/mark
  6945. aZbc
  6946. 0: aZ
  6947. /(?(DEFINE)(a))?b(?1)/
  6948. backgammon
  6949. 0: ba
  6950. /^\N+/
  6951. abc\ndef
  6952. 0: abc
  6953. /^\N{1,}/
  6954. abc\ndef
  6955. 0: abc
  6956. /(?(R)a+|(?R)b)/
  6957. aaaabcde
  6958. 0: aaaab
  6959. /(?(R)a+|((?R))b)/
  6960. aaaabcde
  6961. 0: aaaab
  6962. 1: aaaa
  6963. /((?(R)a+|(?1)b))/
  6964. aaaabcde
  6965. 0: aaaab
  6966. 1: aaaab
  6967. /((?(R1)a+|(?1)b))/
  6968. aaaabcde
  6969. 0: aaaab
  6970. 1: aaaab
  6971. /((?(R)a|(?1)))*/
  6972. aaa
  6973. 0: aaa
  6974. 1: a
  6975. /((?(R)a|(?1)))+/
  6976. aaa
  6977. 0: aaa
  6978. 1: a
  6979. /a(*:any
  6980. name)/mark
  6981. abc
  6982. 0: a
  6983. MK: any \x0aname
  6984. /(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
  6985. a
  6986. 0: a
  6987. ba
  6988. 0: a
  6989. bba
  6990. 0: a
  6991. # Checking revised (*THEN) handling.
  6992. # Capture
  6993. /^.*? (a(*THEN)b) c/x
  6994. \= Expect no match
  6995. aabc
  6996. No match
  6997. /^.*? (a(*THEN)b|(*F)) c/x
  6998. aabc
  6999. 0: aabc
  7000. 1: ab
  7001. /^.*? ( (a(*THEN)b) | (*F) ) c/x
  7002. aabc
  7003. 0: aabc
  7004. 1: ab
  7005. 2: ab
  7006. /^.*? ( (a(*THEN)b) ) c/x
  7007. \= Expect no match
  7008. aabc
  7009. No match
  7010. # Non-capture
  7011. /^.*? (?:a(*THEN)b) c/x
  7012. \= Expect no match
  7013. aabc
  7014. No match
  7015. /^.*? (?:a(*THEN)b|(*F)) c/x
  7016. aabc
  7017. 0: aabc
  7018. /^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
  7019. aabc
  7020. 0: aabc
  7021. /^.*? (?: (?:a(*THEN)b) ) c/x
  7022. \= Expect no match
  7023. aabc
  7024. No match
  7025. # Atomic
  7026. /^.*? (?>a(*THEN)b) c/x
  7027. \= Expect no match
  7028. aabc
  7029. No match
  7030. /^.*? (?>a(*THEN)b|(*F)) c/x
  7031. aabc
  7032. 0: aabc
  7033. /^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
  7034. aabc
  7035. 0: aabc
  7036. /^.*? (?> (?>a(*THEN)b) ) c/x
  7037. \= Expect no match
  7038. aabc
  7039. No match
  7040. # Possessive capture
  7041. /^.*? (a(*THEN)b)++ c/x
  7042. \= Expect no match
  7043. aabc
  7044. No match
  7045. /^.*? (a(*THEN)b|(*F))++ c/x
  7046. aabc
  7047. 0: aabc
  7048. 1: ab
  7049. /^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
  7050. aabc
  7051. 0: aabc
  7052. 1: ab
  7053. 2: ab
  7054. /^.*? ( (a(*THEN)b)++ )++ c/x
  7055. \= Expect no match
  7056. aabc
  7057. No match
  7058. # Possessive non-capture
  7059. /^.*? (?:a(*THEN)b)++ c/x
  7060. \= Expect no match
  7061. aabc
  7062. No match
  7063. /^.*? (?:a(*THEN)b|(*F))++ c/x
  7064. aabc
  7065. 0: aabc
  7066. /^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
  7067. aabc
  7068. 0: aabc
  7069. /^.*? (?: (?:a(*THEN)b)++ )++ c/x
  7070. \= Expect no match
  7071. aabc
  7072. No match
  7073. # Condition assertion
  7074. /^(?(?=a(*THEN)b)ab|ac)/
  7075. ac
  7076. 0: ac
  7077. # Condition
  7078. /^.*?(?(?=a)a|b(*THEN)c)/
  7079. \= Expect no match
  7080. ba
  7081. No match
  7082. /^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
  7083. ba
  7084. 0: ba
  7085. /^.*?(?(?=a)a(*THEN)b|c)/
  7086. \= Expect no match
  7087. ac
  7088. No match
  7089. # Assertion
  7090. /^.*(?=a(*THEN)b)/
  7091. aabc
  7092. 0: a
  7093. # --------------------------
  7094. /(?>a(*:m))/imsx,mark
  7095. a
  7096. 0: a
  7097. MK: m
  7098. /(?>(a)(*:m))/imsx,mark
  7099. a
  7100. 0: a
  7101. 1: a
  7102. MK: m
  7103. /(?<=a(*ACCEPT)b)c/
  7104. xacd
  7105. 0: c
  7106. /(?<=(a(*ACCEPT)b))c/
  7107. xacd
  7108. 0: c
  7109. 1: a
  7110. /(?<=(a(*COMMIT)b))c/
  7111. xabcd
  7112. 0: c
  7113. 1: ab
  7114. \= Expect no match
  7115. xacd
  7116. No match
  7117. /(?<!a(*FAIL)b)c/
  7118. xcd
  7119. 0: c
  7120. acd
  7121. 0: c
  7122. /(?<=a(*:N)b)c/mark
  7123. xabcd
  7124. 0: c
  7125. MK: N
  7126. /(?<=a(*PRUNE)b)c/
  7127. xabcd
  7128. 0: c
  7129. /(?<=a(*SKIP)b)c/
  7130. xabcd
  7131. 0: c
  7132. /(?<=a(*THEN)b)c/
  7133. xabcd
  7134. 0: c
  7135. /(a)(?2){2}(.)/
  7136. abcd
  7137. 0: abcd
  7138. 1: a
  7139. 2: d
  7140. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  7141. C
  7142. 0: C
  7143. 1: C
  7144. MK: B
  7145. \= Expect no match
  7146. D
  7147. No match, mark = B
  7148. /(*MARK:A)(*PRUNE:B)(C|X)/mark
  7149. C
  7150. 0: C
  7151. 1: C
  7152. MK: B
  7153. \= Expect no match
  7154. D
  7155. No match, mark = B
  7156. /(*MARK:A)(*THEN:B)(C|X)/mark
  7157. C
  7158. 0: C
  7159. 1: C
  7160. MK: B
  7161. \= Expect no match
  7162. D
  7163. No match, mark = B
  7164. /(*MARK:A)(*THEN:B)(C|X)/mark,no_start_optimize
  7165. C
  7166. 0: C
  7167. 1: C
  7168. MK: B
  7169. \= Expect no match
  7170. D
  7171. No match, mark = B
  7172. /(*MARK:A)(*THEN:B)(C|X)/mark
  7173. C
  7174. 0: C
  7175. 1: C
  7176. MK: B
  7177. \= Expect no match
  7178. D
  7179. No match, mark = B
  7180. # This should fail, as the skip causes a bump to offset 3 (the skip).
  7181. /A(*MARK:A)A+(*SKIP)(B|Z) | AC/x,mark
  7182. \= Expect no match
  7183. AAAC
  7184. No match, mark = A
  7185. # Same
  7186. /A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/x,mark
  7187. \= Expect no match
  7188. AAAC
  7189. No match, mark = B
  7190. /A(*:A)A+(*SKIP)(B|Z) | AC/x,mark
  7191. \= Expect no match
  7192. AAAC
  7193. No match, mark = A
  7194. # This should fail, as a null name is the same as no name.
  7195. /A(*MARK:A)A+(*SKIP:)(B|Z) | AC/x,mark
  7196. \= Expect no match
  7197. AAAC
  7198. No match, mark = A
  7199. # A check on what happens after hitting a mark and them bumping along to
  7200. # something that does not even start. Perl reports tags after the failures
  7201. # here, though it does not when the individual letters are made into something
  7202. # more complicated.
  7203. /A(*:A)B|XX(*:B)Y/mark
  7204. AABC
  7205. 0: AB
  7206. MK: A
  7207. XXYZ
  7208. 0: XXY
  7209. MK: B
  7210. \= Expect no match
  7211. XAQQ
  7212. No match, mark = A
  7213. XAQQXZZ
  7214. No match, mark = A
  7215. AXQQQ
  7216. No match, mark = A
  7217. AXXQQQ
  7218. No match, mark = B
  7219. /^(A(*THEN:A)B|C(*THEN:B)D)/mark
  7220. AB
  7221. 0: AB
  7222. 1: AB
  7223. MK: A
  7224. CD
  7225. 0: CD
  7226. 1: CD
  7227. MK: B
  7228. \= Expect no match
  7229. AC
  7230. No match, mark = A
  7231. CB
  7232. No match, mark = B
  7233. /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
  7234. AB
  7235. 0: AB
  7236. 1: AB
  7237. MK: A
  7238. CD
  7239. 0: CD
  7240. 1: CD
  7241. MK: B
  7242. \= Expect no match
  7243. AC
  7244. No match, mark = A
  7245. CB
  7246. No match, mark = B
  7247. # An empty name does not pass back an empty string. It is the same as if no
  7248. # name were given.
  7249. /^(A(*PRUNE:)B|C(*PRUNE:B)D)/mark
  7250. AB
  7251. 0: AB
  7252. 1: AB
  7253. CD
  7254. 0: CD
  7255. 1: CD
  7256. MK: B
  7257. # PRUNE goes to next bumpalong; COMMIT does not.
  7258. /A(*PRUNE:A)B/mark
  7259. ACAB
  7260. 0: AB
  7261. MK: A
  7262. # Mark names can be duplicated.
  7263. /A(*:A)B|X(*:A)Y/mark
  7264. AABC
  7265. 0: AB
  7266. MK: A
  7267. XXYZ
  7268. 0: XY
  7269. MK: A
  7270. /b(*:m)f|a(*:n)w/mark
  7271. aw
  7272. 0: aw
  7273. MK: n
  7274. \= Expect no match
  7275. abc
  7276. No match, mark = m
  7277. /b(*:m)f|aw/mark
  7278. abaw
  7279. 0: aw
  7280. \= Expect no match
  7281. abc
  7282. No match, mark = m
  7283. abax
  7284. No match, mark = m
  7285. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/x,mark
  7286. AAAC
  7287. 0: AAC
  7288. /(?=a(*MARK:A)b)..x/mark
  7289. abxy
  7290. 0: abx
  7291. MK: A
  7292. \= Expect no match
  7293. abpq
  7294. No match
  7295. /(?=a(*MARK:A)b)..(*:Y)x/mark
  7296. abxy
  7297. 0: abx
  7298. MK: Y
  7299. \= Expect no match
  7300. abpq
  7301. No match
  7302. /(?=a(*PRUNE:A)b)..x/mark
  7303. abxy
  7304. 0: abx
  7305. MK: A
  7306. \= Expect no match
  7307. abpq
  7308. No match
  7309. /(?=a(*PRUNE:A)b)..(*:Y)x/mark
  7310. abxy
  7311. 0: abx
  7312. MK: Y
  7313. \= Expect no match
  7314. abpq
  7315. No match
  7316. /(?=a(*THEN:A)b)..x/mark
  7317. abxy
  7318. 0: abx
  7319. MK: A
  7320. \= Expect no match
  7321. abpq
  7322. No match
  7323. /(?=a(*THEN:A)b)..(*:Y)x/mark
  7324. abxy
  7325. 0: abx
  7326. MK: Y
  7327. \= Expect no match
  7328. abpq
  7329. No match
  7330. /(another)?(\1?)test/
  7331. hello world test
  7332. 0: test
  7333. 1: <unset>
  7334. 2:
  7335. /(another)?(\1+)test/
  7336. \= Expect no match
  7337. hello world test
  7338. No match
  7339. /(a(*COMMIT)b){0}a(?1)|aac/
  7340. aac
  7341. 0: aac
  7342. /((?:a?)*)*c/
  7343. aac
  7344. 0: aac
  7345. 1:
  7346. /((?>a?)*)*c/
  7347. aac
  7348. 0: aac
  7349. 1:
  7350. /(?>.*?a)(?<=ba)/
  7351. aba
  7352. 0: ba
  7353. /(?:.*?a)(?<=ba)/
  7354. aba
  7355. 0: aba
  7356. /(?>.*?a)b/s
  7357. aab
  7358. 0: ab
  7359. /(?>.*?a)b/
  7360. aab
  7361. 0: ab
  7362. /(?>^a)b/s
  7363. \= Expect no match
  7364. aab
  7365. No match
  7366. /(?>.*?)(?<=(abcd)|(wxyz))/
  7367. alphabetabcd
  7368. 0:
  7369. 1: abcd
  7370. endingwxyz
  7371. 0:
  7372. 1: <unset>
  7373. 2: wxyz
  7374. /(?>.*)(?<=(abcd)|(wxyz))/
  7375. alphabetabcd
  7376. 0: alphabetabcd
  7377. 1: abcd
  7378. endingwxyz
  7379. 0: endingwxyz
  7380. 1: <unset>
  7381. 2: wxyz
  7382. /(?>.*)foo/
  7383. \= Expect no match
  7384. abcdfooxyz
  7385. No match
  7386. /(?>.*?)foo/
  7387. abcdfooxyz
  7388. 0: foo
  7389. /(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/
  7390. ac
  7391. 0: ac
  7392. /(?:(a(*SKIP)b)){0}(?:(?1)|ac)/
  7393. ac
  7394. 0: ac
  7395. /(?<=(*SKIP)ac)a/
  7396. \= Expect no match
  7397. aa
  7398. No match
  7399. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
  7400. AAAC
  7401. 0: AC
  7402. /a(*SKIP:m)x|ac(*:n)(*SKIP:n)d|ac/mark
  7403. acacd
  7404. 0: acd
  7405. MK: n
  7406. /A(*SKIP:m)x|A(*SKIP:n)x|AB/mark
  7407. AB
  7408. 0: AB
  7409. /((*SKIP:r)d){0}a(*SKIP:m)x|ac(*:n)|ac/mark
  7410. acacd
  7411. 0: ac
  7412. MK: n
  7413. # Tests that try to figure out how Perl works. My hypothesis is that the first
  7414. # verb that is backtracked onto is the one that acts. This seems to be the case
  7415. # almost all the time, but there is one exception that is perhaps a bug.
  7416. # This matches "aaaac"; each PRUNE advances one character until the subject no
  7417. # longer starts with 5 'a's.
  7418. /aaaaa(*PRUNE)b|a+c/
  7419. aaaaaac
  7420. 0: aaaac
  7421. # Putting SKIP in front of PRUNE makes no difference, as it is never
  7422. # backtracked onto, whether or not it has a label.
  7423. /aaaaa(*SKIP)(*PRUNE)b|a+c/
  7424. aaaaaac
  7425. 0: aaaac
  7426. /aaaaa(*SKIP:N)(*PRUNE)b|a+c/
  7427. aaaaaac
  7428. 0: aaaac
  7429. /aaaa(*:N)a(*SKIP:N)(*PRUNE)b|a+c/
  7430. aaaaaac
  7431. 0: aaaac
  7432. # Putting THEN in front makes no difference.
  7433. /aaaaa(*THEN)(*PRUNE)b|a+c/
  7434. aaaaaac
  7435. 0: aaaac
  7436. # However, putting COMMIT in front of the prune changes it to "no match". I
  7437. # think this is inconsistent and possibly a bug. For the moment, running this
  7438. # test is moved out of the Perl-compatible file.
  7439. /aaaaa(*COMMIT)(*PRUNE)b|a+c/
  7440. # OK, lets play the same game again using SKIP instead of PRUNE.
  7441. # This matches "ac" because SKIP forces the next match to start on the
  7442. # sixth "a".
  7443. /aaaaa(*SKIP)b|a+c/
  7444. aaaaaac
  7445. 0: ac
  7446. # Putting PRUNE in front makes no difference.
  7447. /aaaaa(*PRUNE)(*SKIP)b|a+c/
  7448. aaaaaac
  7449. 0: ac
  7450. # Putting THEN in front makes no difference.
  7451. /aaaaa(*THEN)(*SKIP)b|a+c/
  7452. aaaaaac
  7453. 0: ac
  7454. # In this case, neither does COMMIT. This still matches "ac".
  7455. /aaaaa(*COMMIT)(*SKIP)b|a+c/
  7456. aaaaaac
  7457. 0: ac
  7458. # This gives "no match", as expected.
  7459. /aaaaa(*COMMIT)b|a+c/
  7460. \= Expect no match
  7461. aaaaaac
  7462. No match
  7463. # ---- Tests using THEN ----
  7464. # This matches "aaaaaac", as expected.
  7465. /aaaaa(*THEN)b|a+c/
  7466. aaaaaac
  7467. 0: aaaaaac
  7468. # Putting SKIP in front makes no difference.
  7469. /aaaaa(*SKIP)(*THEN)b|a+c/
  7470. aaaaaac
  7471. 0: aaaaaac
  7472. # Putting PRUNE in front makes no difference.
  7473. /aaaaa(*PRUNE)(*THEN)b|a+c/
  7474. aaaaaac
  7475. 0: aaaaaac
  7476. # Putting COMMIT in front makes no difference.
  7477. /aaaaa(*COMMIT)(*THEN)b|a+c/
  7478. aaaaaac
  7479. 0: aaaaaac
  7480. # End of "priority" tests
  7481. /aaaaa(*:m)(*PRUNE:m)(*SKIP:m)m|a+/
  7482. aaaaaa
  7483. 0: a
  7484. /aaaaa(*:m)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  7485. aaaaaa
  7486. 0: a
  7487. /aaaaa(*:n)(*PRUNE:m)(*SKIP:m)m|a+/
  7488. aaaaaa
  7489. 0: aaaa
  7490. /aaaaa(*:n)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
  7491. aaaaaa
  7492. 0: a
  7493. /a(*MARK:A)aa(*PRUNE:A)a(*SKIP:A)b|a+c/
  7494. aaaac
  7495. 0: aac
  7496. /a(*MARK:A)aa(*MARK:A)a(*SKIP:A)b|a+c/
  7497. aaaac
  7498. 0: ac
  7499. /aaa(*PRUNE:A)a(*SKIP:A)b|a+c/
  7500. aaaac
  7501. 0: aac
  7502. /aaa(*MARK:A)a(*SKIP:A)b|a+c/
  7503. aaaac
  7504. 0: ac
  7505. /a(*:m)a(*COMMIT)(*SKIP:m)b|a+c/mark
  7506. aaaaaac
  7507. 0: ac
  7508. /.?(a|b(*THEN)c)/
  7509. ba
  7510. 0: ba
  7511. 1: a
  7512. /(a(*COMMIT)b)c|abd/
  7513. abc
  7514. 0: abc
  7515. 1: ab
  7516. \= Expect no match
  7517. abd
  7518. No match
  7519. /(?=a(*COMMIT)b)abc|abd/
  7520. abc
  7521. 0: abc
  7522. abd
  7523. 0: abd
  7524. /(?>a(*COMMIT)b)c|abd/
  7525. abc
  7526. 0: abc
  7527. abd
  7528. 0: abd
  7529. /a(?=b(*COMMIT)c)[^d]|abd/
  7530. abc
  7531. 0: ab
  7532. \= Expect no match
  7533. abd
  7534. No match
  7535. /a(?=bc).|abd/
  7536. abd
  7537. 0: abd
  7538. abc
  7539. 0: ab
  7540. /a(?>b(*COMMIT)c)d|abd/
  7541. \= Expect no match
  7542. abceabd
  7543. No match
  7544. /a(?>bc)d|abd/
  7545. abceabd
  7546. 0: abd
  7547. /(?>a(*COMMIT)b)c|abd/
  7548. abd
  7549. 0: abd
  7550. /(?>a(*COMMIT)c)d|abd/
  7551. \= Expect no match
  7552. abd
  7553. No match
  7554. /((?=a(*COMMIT)b)ab|ac){0}(?:(?1)|a(c))/
  7555. ac
  7556. 0: ac
  7557. 1: <unset>
  7558. 2: c
  7559. # These tests were formerly in test 2, but changes in PCRE and Perl have
  7560. # made them compatible.
  7561. /^(a)?(?(1)a|b)+$/
  7562. \= Expect no match
  7563. a
  7564. No match
  7565. /A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark
  7566. \= Expect no match
  7567. AAAC
  7568. No match, mark = A
  7569. /^((abc|abcx)(*THEN)y|abcd)/
  7570. abcd
  7571. 0: abcd
  7572. 1: abcd
  7573. \= Expect no match
  7574. abcxy
  7575. No match
  7576. /^((yes|no)(*THEN)(*F))?/
  7577. \= Expect no match
  7578. yes
  7579. No match
  7580. /(A (.*) C? (*THEN) | A D) (*FAIL)/x
  7581. \= Expect no match
  7582. AbcdCBefgBhiBqz
  7583. No match
  7584. /(A (.*) C? (*THEN) | A D) z/x
  7585. \= Expect no match
  7586. AbcdCBefgBhiBqz
  7587. No match
  7588. /(A (.*) C? (*THEN) | A D) \s* (*FAIL)/x
  7589. \= Expect no match
  7590. AbcdCBefgBhiBqz
  7591. No match
  7592. /(A (.*) C? (*THEN) | A D) \s* z/x
  7593. \= Expect no match
  7594. AbcdCBefgBhiBqz
  7595. No match
  7596. /(A (.*) (?:C|) (*THEN) | A D) (*FAIL)/x
  7597. \= Expect no match
  7598. AbcdCBefgBhiBqz
  7599. No match
  7600. /(A (.*) (?:C|) (*THEN) | A D) z/x
  7601. \= Expect no match
  7602. AbcdCBefgBhiBqz
  7603. No match
  7604. /(A (.*) C{0,6} (*THEN) | A D) (*FAIL)/x
  7605. \= Expect no match
  7606. AbcdCBefgBhiBqz
  7607. No match
  7608. /(A (.*) C{0,6} (*THEN) | A D) z/x
  7609. \= Expect no match
  7610. AbcdCBefgBhiBqz
  7611. No match
  7612. /(A (.*) (CE){0,6} (*THEN) | A D) (*FAIL)/x
  7613. \= Expect no match
  7614. AbcdCEBefgBhiBqz
  7615. No match
  7616. /(A (.*) (CE){0,6} (*THEN) | A D) z/x
  7617. \= Expect no match
  7618. AbcdCEBefgBhiBqz
  7619. No match
  7620. /(A (.*) (CE*){0,6} (*THEN) | A D) (*FAIL)/x
  7621. \= Expect no match
  7622. AbcdCBefgBhiBqz
  7623. No match
  7624. /(A (.*) (CE*){0,6} (*THEN) | A D) z/x
  7625. \= Expect no match
  7626. AbcdCBefgBhiBqz
  7627. No match
  7628. /(?=a(*COMMIT)b|ac)ac|ac/
  7629. \= Expect no match
  7630. ac
  7631. No match
  7632. /(?=a(*COMMIT)b|(ac)) ac | (a)c/x
  7633. \= Expect no match
  7634. ac
  7635. No match
  7636. # ----
  7637. /(?(?!b(*THEN)a)bn|bnn)/
  7638. bnn
  7639. 0: bn
  7640. /(?!b(*SKIP)a)bn|bnn/
  7641. bnn
  7642. 0: bn
  7643. /(?(?!b(*SKIP)a)bn|bnn)/
  7644. bnn
  7645. 0: bn
  7646. /(?!b(*PRUNE)a)bn|bnn/
  7647. bnn
  7648. 0: bn
  7649. /(?(?!b(*PRUNE)a)bn|bnn)/
  7650. bnn
  7651. 0: bn
  7652. /(?!b(*COMMIT)a)bn|bnn/
  7653. bnn
  7654. 0: bn
  7655. /(?(?!b(*COMMIT)a)bn|bnn)/
  7656. bnn
  7657. 0: bn
  7658. /(?=b(*SKIP)a)bn|bnn/
  7659. \= Expect no match
  7660. bnn
  7661. No match
  7662. /(?=b(*THEN)a)bn|bnn/
  7663. bnn
  7664. 0: bnn
  7665. /^(?!a(*SKIP)b)/
  7666. ac
  7667. 0:
  7668. /^(?!a(*SKIP)b)../
  7669. acd
  7670. 0: ac
  7671. /(?!a(*SKIP)b)../
  7672. acd
  7673. 0: ac
  7674. /^(?(?!a(*SKIP)b))/
  7675. ac
  7676. 0:
  7677. /^(?!a(*PRUNE)b)../
  7678. acd
  7679. 0: ac
  7680. /(?!a(*PRUNE)b)../
  7681. acd
  7682. 0: ac
  7683. /(?!a(*COMMIT)b)ac|cd/
  7684. ac
  7685. 0: ac
  7686. /\A.*?(?:a|bc)/
  7687. ba
  7688. 0: ba
  7689. /^(A(*THEN)B|C(*THEN)D)/
  7690. CD
  7691. 0: CD
  7692. 1: CD
  7693. /(*:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  7694. abc
  7695. 0: b
  7696. MK: m(m
  7697. /(*PRUNE:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  7698. abc
  7699. 0: b
  7700. MK: m(m
  7701. /(*SKIP:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  7702. abc
  7703. 0: b
  7704. /(*THEN:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
  7705. abc
  7706. 0: b
  7707. MK: m(m
  7708. /^\d*\w{4}/
  7709. 1234
  7710. 0: 1234
  7711. \= Expect no match
  7712. 123
  7713. No match
  7714. /^[^b]*\w{4}/
  7715. aaaa
  7716. 0: aaaa
  7717. \= Expect no match
  7718. aaa
  7719. No match
  7720. /^[^b]*\w{4}/i
  7721. aaaa
  7722. 0: aaaa
  7723. \= Expect no match
  7724. aaa
  7725. No match
  7726. /^a*\w{4}/
  7727. aaaa
  7728. 0: aaaa
  7729. \= Expect no match
  7730. aaa
  7731. No match
  7732. /^a*\w{4}/i
  7733. aaaa
  7734. 0: aaaa
  7735. \= Expect no match
  7736. aaa
  7737. No match
  7738. /(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  7739. foofoo
  7740. 0: foofoo
  7741. 1: foo
  7742. barbar
  7743. 0: barbar
  7744. 1: <unset>
  7745. 2: bar
  7746. /(?<n>A)(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
  7747. AfooA
  7748. 0: AfooA
  7749. 1: A
  7750. 2: foo
  7751. AbarA
  7752. 0: AbarA
  7753. 1: A
  7754. 2: <unset>
  7755. 3: bar
  7756. \= Expect no match
  7757. Afoofoo
  7758. No match
  7759. Abarbar
  7760. No match
  7761. /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
  7762. 1 IN SOA non-sp1 non-sp2(
  7763. 0: 1 IN SOA non-sp1 non-sp2(
  7764. 1: 1
  7765. 2: non-sp1
  7766. 3: non-sp2
  7767. /^ (?:(?<A>A)|(?'B'B)(?<A>A)) (?('A')x) (?(<B>)y)$/x,dupnames
  7768. Ax
  7769. 0: Ax
  7770. 1: A
  7771. BAxy
  7772. 0: BAxy
  7773. 1: <unset>
  7774. 2: B
  7775. 3: A
  7776. /^A\xZ/
  7777. A\0Z
  7778. 0: A\x00Z
  7779. /^A\o{123}B/
  7780. A\123B
  7781. 0: ASB
  7782. / ^ a + + b $ /x
  7783. aaaab
  7784. 0: aaaab
  7785. / ^ a + #comment
  7786. + b $ /x
  7787. aaaab
  7788. 0: aaaab
  7789. / ^ a + #comment
  7790. #comment
  7791. + b $ /x
  7792. aaaab
  7793. 0: aaaab
  7794. / ^ (?> a + ) b $ /x
  7795. aaaab
  7796. 0: aaaab
  7797. / ^ ( a + ) + + \w $ /x
  7798. aaaab
  7799. 0: aaaab
  7800. 1: aaaa
  7801. /(?:a\Kb)*+/aftertext
  7802. ababc
  7803. 0: b
  7804. 0+ c
  7805. /(?>a\Kb)*/aftertext
  7806. ababc
  7807. 0: b
  7808. 0+ c
  7809. /(?:a\Kb)*/aftertext
  7810. ababc
  7811. 0: b
  7812. 0+ c
  7813. /(a\Kb)*+/aftertext
  7814. ababc
  7815. 0: b
  7816. 0+ c
  7817. 1: ab
  7818. /(a\Kb)*/aftertext
  7819. ababc
  7820. 0: b
  7821. 0+ c
  7822. 1: ab
  7823. /(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
  7824. \= Expect no match
  7825. acb
  7826. No match
  7827. /\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++/
  7828. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  7829. 0: NON QUOTED "QUOT""ED" AFTER
  7830. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++/
  7831. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  7832. 0: NON QUOTED "QUOT""ED" AFTER
  7833. /\A(?:[^\"]++|\"(?:[^\"]++|\"\")++\")++/
  7834. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  7835. 0: NON QUOTED "QUOT""ED" AFTER
  7836. /\A([^\"1]++|[\"2]([^\"3]*+|[\"4][\"5])*+[\"6])++/
  7837. NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
  7838. 0: NON QUOTED "QUOT""ED" AFTER
  7839. 1: AFTER
  7840. 2:
  7841. /^\w+(?>\s*)(?<=\w)/
  7842. test test
  7843. 0: tes
  7844. /(?P<same>a)(?P<same>b)/g,dupnames
  7845. abbaba
  7846. 0: ab
  7847. 1: a
  7848. 2: b
  7849. 0: ab
  7850. 1: a
  7851. 2: b
  7852. /(?P<same>a)(?P<same>b)(?P=same)/g,dupnames
  7853. abbaba
  7854. 0: aba
  7855. 1: a
  7856. 2: b
  7857. /(?P=same)?(?P<same>a)(?P<same>b)/g,dupnames
  7858. abbaba
  7859. 0: ab
  7860. 1: a
  7861. 2: b
  7862. 0: ab
  7863. 1: a
  7864. 2: b
  7865. /(?:(?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
  7866. \= Expect no match
  7867. bbbaaaccccaaabbbcc
  7868. No match
  7869. /(?P<Name>a)?(?P<Name2>b)?(?(<Name>)c|d)*l/
  7870. acl
  7871. 0: acl
  7872. 1: a
  7873. bdl
  7874. 0: bdl
  7875. 1: <unset>
  7876. 2: b
  7877. adl
  7878. 0: dl
  7879. bcl
  7880. 0: l
  7881. /\sabc/
  7882. \x{0b}abc
  7883. 0: \x0babc
  7884. /[\Qa]\E]+/
  7885. aa]]
  7886. 0: aa]]
  7887. /[\Q]a\E]+/
  7888. aa]]
  7889. 0: aa]]
  7890. /A((((((((a))))))))\8B/
  7891. AaaB
  7892. 0: AaaB
  7893. 1: a
  7894. 2: a
  7895. 3: a
  7896. 4: a
  7897. 5: a
  7898. 6: a
  7899. 7: a
  7900. 8: a
  7901. /A(((((((((a)))))))))\9B/
  7902. AaaB
  7903. 0: AaaB
  7904. 1: a
  7905. 2: a
  7906. 3: a
  7907. 4: a
  7908. 5: a
  7909. 6: a
  7910. 7: a
  7911. 8: a
  7912. 9: a
  7913. /A[\8\9]B/
  7914. A8B
  7915. 0: A8B
  7916. A9B
  7917. 0: A9B
  7918. /(|ab)*?d/
  7919. abd
  7920. 0: abd
  7921. 1: ab
  7922. xyd
  7923. 0: d
  7924. /(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
  7925. 1234abcd
  7926. 0:
  7927. 1: <unset>
  7928. 2: <unset>
  7929. 3: <unset>
  7930. 4: <unset>
  7931. 5:
  7932. /(\2|a)(\1)/
  7933. aaa
  7934. 0: aa
  7935. 1: a
  7936. 2: a
  7937. /(\2)(\1)/
  7938. /Z*(|d*){216}/
  7939. /(?1)(?#?'){8}(a)/
  7940. baaaaaaaaac
  7941. 0: aaaaaaaaa
  7942. 1: a
  7943. /((((((((((((x))))))))))))\12/
  7944. xx
  7945. 0: xx
  7946. 1: x
  7947. 2: x
  7948. 3: x
  7949. 4: x
  7950. 5: x
  7951. 6: x
  7952. 7: x
  7953. 8: x
  7954. 9: x
  7955. 10: x
  7956. 11: x
  7957. 12: x
  7958. /A[\8]B[\9]C/
  7959. A8B9C
  7960. 0: A8B9C
  7961. /(?1)()((((((\1++))\x85)+)|))/
  7962. \x85\x85
  7963. 0: \x85\x85
  7964. 1:
  7965. 2: \x85\x85
  7966. 3: \x85\x85
  7967. 4: \x85\x85
  7968. 5: \x85
  7969. 6:
  7970. 7:
  7971. /(?|(\k'Pm')|(?'Pm'))/
  7972. abcd
  7973. 0:
  7974. 1:
  7975. /(?|(aaa)|(b))\g{1}/
  7976. aaaaaa
  7977. 0: aaaaaa
  7978. 1: aaa
  7979. bb
  7980. 0: bb
  7981. 1: b
  7982. /(?|(aaa)|(b))(?1)/
  7983. aaaaaa
  7984. 0: aaaaaa
  7985. 1: aaa
  7986. baaa
  7987. 0: baaa
  7988. 1: b
  7989. \= Expect no match
  7990. bb
  7991. No match
  7992. /(?|(aaa)|(b))/
  7993. xaaa
  7994. 0: aaa
  7995. 1: aaa
  7996. xbc
  7997. 0: b
  7998. 1: b
  7999. /(?|(?'a'aaa)|(?'a'b))\k'a'/
  8000. aaaaaa
  8001. 0: aaaaaa
  8002. 1: aaa
  8003. bb
  8004. 0: bb
  8005. 1: b
  8006. /(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/dupnames
  8007. aaaccccaaa
  8008. 0: aaaccccaaa
  8009. 1: aaa
  8010. 2: cccc
  8011. bccccb
  8012. 0: bccccb
  8013. 1: b
  8014. 2: cccc
  8015. # /x does not apply to MARK labels
  8016. /x (*MARK:ab cd # comment
  8017. ef) x/x,mark
  8018. axxz
  8019. 0: xx
  8020. MK: ab cd # comment\x0aef
  8021. /(?<=a(B){0}c)X/
  8022. acX
  8023. 0: X
  8024. /(?<DEFINE>b)(?(DEFINE)(a+))(?&DEFINE)/
  8025. bbbb
  8026. 0: bb
  8027. 1: b
  8028. \= Expect no match
  8029. baaab
  8030. No match
  8031. /(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])/
  8032. \ Fred:099
  8033. 0:
  8034. /(?=.*X)X$/
  8035. \ X
  8036. 0: X
  8037. /(?s)(?=.*?)b/
  8038. aabc
  8039. 0: b
  8040. /(Z)(a)\2{1,2}?(?-i)\1X/i
  8041. ZaAAZX
  8042. 0: ZaAAZX
  8043. 1: Z
  8044. 2: a
  8045. /(?'c')XX(?'YYYYYYYYYYYYYYYYYYYYYYYCl')/
  8046. /[s[:digit:]\E-H]+/
  8047. s09-H
  8048. 0: s09-H
  8049. /[s[:digit:]\Q\E-H]+/
  8050. s09-H
  8051. 0: s09-H
  8052. /a+(?:|b)a/
  8053. aaaa
  8054. 0: aaaa
  8055. /X?(R||){3335}/
  8056. /(?1)(A(*COMMIT)|B)D/
  8057. ABD
  8058. 0: ABD
  8059. 1: B
  8060. XABD
  8061. 0: ABD
  8062. 1: B
  8063. BAD
  8064. 0: BAD
  8065. 1: A
  8066. ABXABD
  8067. 0: ABD
  8068. 1: B
  8069. \= Expect no match
  8070. ABX
  8071. No match
  8072. /(?(DEFINE)(?<m> 1? (?=(?<cond>2)?) 1 2 (?('cond')|3)))
  8073. \A
  8074. ()
  8075. (?&m)
  8076. \Z/x
  8077. 123
  8078. 0: 123
  8079. 1: <unset>
  8080. 2: <unset>
  8081. 3:
  8082. /^(?:
  8083. (?: A| (1? (?=(?<cond>2)?) (1) 2 (?('cond')|3)) )
  8084. (Z)
  8085. )+$/x
  8086. AZ123Z
  8087. 0: AZ123Z
  8088. 1: 123
  8089. 2: <unset>
  8090. 3: 1
  8091. 4: Z
  8092. \= Expect no match
  8093. AZ12Z
  8094. No match
  8095. /^ (?(DEFINE) ( (?!(a)\2b)..) ) ()(?1) /x
  8096. acb
  8097. 0: ac
  8098. 1: <unset>
  8099. 2: <unset>
  8100. 3:
  8101. \= Expect no match
  8102. aab
  8103. No match
  8104. /(?>ab|abab){1,5}?M/
  8105. abababababababababababM
  8106. 0: abababababM
  8107. /(?>ab|abab){2}?M/
  8108. abababM
  8109. 0: ababM
  8110. /((?(?=(a))a)+k)/
  8111. bbak
  8112. 0: ak
  8113. 1: ak
  8114. 2: a
  8115. /((?(?=(a))a|)+k)/
  8116. bbak
  8117. 0: ak
  8118. 1: ak
  8119. 2: a
  8120. /(?(?!(b))a|b)+k/
  8121. ababbalbbadabak
  8122. 0: abak
  8123. 1: b
  8124. /(?!(b))c|b/
  8125. Ab
  8126. 0: b
  8127. Ac
  8128. 0: c
  8129. /(?=(b))b|c/
  8130. Ab
  8131. 0: b
  8132. 1: b
  8133. Ac
  8134. 0: c
  8135. /^(.|(.)(?1)\2)$/
  8136. a
  8137. 0: a
  8138. 1: a
  8139. aba
  8140. 0: aba
  8141. 1: aba
  8142. 2: a
  8143. abcba
  8144. 0: abcba
  8145. 1: abcba
  8146. 2: a
  8147. ababa
  8148. 0: ababa
  8149. 1: ababa
  8150. 2: a
  8151. abcdcba
  8152. 0: abcdcba
  8153. 1: abcdcba
  8154. 2: a
  8155. /^((.)(?1)\2|.?)$/
  8156. a
  8157. 0: a
  8158. 1: a
  8159. aba
  8160. 0: aba
  8161. 1: aba
  8162. 2: a
  8163. abba
  8164. 0: abba
  8165. 1: abba
  8166. 2: a
  8167. abcba
  8168. 0: abcba
  8169. 1: abcba
  8170. 2: a
  8171. ababa
  8172. 0: ababa
  8173. 1: ababa
  8174. 2: a
  8175. abccba
  8176. 0: abccba
  8177. 1: abccba
  8178. 2: a
  8179. abcdcba
  8180. 0: abcdcba
  8181. 1: abcdcba
  8182. 2: a
  8183. abcddcba
  8184. 0: abcddcba
  8185. 1: abcddcba
  8186. 2: a
  8187. /^(.)(\1|a(?2))/
  8188. bab
  8189. 0: bab
  8190. 1: b
  8191. 2: ab
  8192. /^(.|(.)(?1)?\2)$/
  8193. abcba
  8194. 0: abcba
  8195. 1: abcba
  8196. 2: a
  8197. /^(?(?=(a))abc|def)/
  8198. abc
  8199. 0: abc
  8200. 1: a
  8201. /^(?(?!(a))def|abc)/
  8202. abc
  8203. 0: abc
  8204. 1: a
  8205. /^(?(?=(a)(*ACCEPT))abc|def)/
  8206. abc
  8207. 0: abc
  8208. 1: a
  8209. /^(?(?!(a)(*ACCEPT))def|abc)/
  8210. abc
  8211. 0: abc
  8212. 1: a
  8213. /^(?1)\d{3}(a)/
  8214. a123a
  8215. 0: a123a
  8216. 1: a
  8217. # This pattern uses a lot of named subpatterns in order to match email
  8218. # addresses in various formats. It's a heavy test for named subpatterns. In the
  8219. # <atext> group, slash is coded as \x{2f} so that this pattern can also be
  8220. # processed by perltest.sh, which does not cater for an escaped delimiter
  8221. # within the pattern. $ within the pattern must also be escaped. All $ and @
  8222. # characters in subject strings are escaped so that Perl doesn't interpret them
  8223. # as variable insertions and " characters must also be escaped for Perl.
  8224. # This set of subpatterns is more or less a direct transliteration of the BNF
  8225. # definitions in RFC2822, without any of the obsolete features. The addition of
  8226. # a possessive + to the definition of <phrase> reduced the match limit in PCRE2
  8227. # from over 5 million to just under 400, and eliminated a very noticeable delay
  8228. # when this file was passed to perltest.sh.
  8229. /(?ix)(?(DEFINE)
  8230. (?<addr_spec> (?&local_part) \@ (?&domain) )
  8231. (?<angle_addr> (?&CFWS)?+ < (?&addr_spec) > (?&CFWS)?+ )
  8232. (?<atext> [a-z\d!#\$%&'*+-\x{2f}=?^_`{|}~] )
  8233. (?<atom> (?&CFWS)?+ (?&atext)+ (?&CFWS)?+ )
  8234. (?<ccontent> (?&ctext) | (?&quoted_pair) | (?&comment) )
  8235. (?<ctext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ ()\\] )
  8236. (?<comment> \( (?: (?&FWS)?+ (?&ccontent) )*+ (?&FWS)?+ \) )
  8237. (?<CFWS> (?: (?&FWS)?+ (?&comment) )* (?# NOT possessive)
  8238. (?: (?&FWS)?+ (?&comment) | (?&FWS) ) )
  8239. (?<dcontent> (?&dtext) | (?&quoted_pair) )
  8240. (?<display_name> (?&phrase) )
  8241. (?<domain> (?&dot_atom) | (?&domain_literal) )
  8242. (?<domain_literal> (?&CFWS)?+ \[ (?: (?&FWS)?+ (?&dcontent) )* (?&FWS)?+ \]
  8243. (?&CFWS)?+ )
  8244. (?<dot_atom> (?&CFWS)?+ (?&dot_atom_text) (?&CFWS)?+ )
  8245. (?<dot_atom_text> (?&atext)++ (?: \. (?&atext)++)*+ )
  8246. (?<dtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ \[\]\\] )
  8247. (?<FWS> (?: [\t\ ]*+ \n)?+ [\t\ ]++ )
  8248. (?<local_part> (?&dot_atom) | (?&quoted_string) )
  8249. (?<mailbox> (?&name_addr) | (?&addr_spec) )
  8250. (?<name_addr> (?&display_name)? (?&angle_addr) )
  8251. (?<phrase> (?&word)++ )
  8252. (?<qcontent> (?&qtext) | (?&quoted_pair) )
  8253. (?<quoted_pair> " (?&text) )
  8254. (?<quoted_string> (?&CFWS)?+ " (?: (?&FWS)?+ (?&qcontent))* (?&FWS)?+ "
  8255. (?&CFWS)?+ )
  8256. (?<qtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ "\\] )
  8257. (?<text> [^\r\n] )
  8258. (?<word> (?&atom) | (?&quoted_string) )
  8259. ) # End DEFINE
  8260. ^(?&mailbox)$/
  8261. Alan Other <user\@dom.ain>
  8262. 0: Alan Other <[email protected]>
  8263. <user\@dom.ain>
  8264. 0: <[email protected]>
  8265. user\@dom.ain
  8266. 0: [email protected]
  8267. user\@[]
  8268. 0: user@[]
  8269. user\@[domain literal]
  8270. 0: user@[domain literal]
  8271. user\@[domain literal with \"[square brackets\"] inside]
  8272. 0: user@[domain literal with "[square brackets"] inside]
  8273. \"A. Other\" <user.1234\@dom.ain> (a comment)
  8274. 0: "A. Other" <[email protected]> (a comment)
  8275. A. Other <user.1234\@dom.ain> (a comment)
  8276. 0: A. Other <[email protected]> (a comment)
  8277. \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
  8278. 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
  8279. \= Expect no match
  8280. A missing angle <user\@some.where
  8281. No match
  8282. The quick brown fox
  8283. No match
  8284. # --------------------------------------------------------------------------
  8285. # This pattern uses named groups to match default PCRE2 patterns. It's another
  8286. # heavy test for named subpatterns. Once again, code slash as \x{2f} and escape
  8287. # $ even in classes so that this works with pcre2test.
  8288. /(?sx)(?(DEFINE)
  8289. (?<assertion> (?&simple_assertion) | (?&lookaround) )
  8290. (?<atomic_group> \( \? > (?&regex) \) )
  8291. (?<back_reference> \\ \d+ |
  8292. \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) |
  8293. \\k <(?&groupname)> |
  8294. \\k '(?&groupname)' |
  8295. \\k \{ (?&groupname) \} |
  8296. \( \? P= (?&groupname) \) )
  8297. (?<branch> (?:(?&assertion) |
  8298. (?&callout) |
  8299. (?&comment) |
  8300. (?&option_setting) |
  8301. (?&qualified_item) |
  8302. (?&quoted_string) |
  8303. (?&quoted_string_empty) |
  8304. (?&special_escape) |
  8305. (?&verb)
  8306. )* )
  8307. (?<callout> \(\?C (?: \d+ |
  8308. (?: (?<D>["'`^%\#\$])
  8309. (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' |
  8310. \{ (?: \}\} | [^}]*+ )* \} )
  8311. )? \) )
  8312. (?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )?
  8313. (?&regex) \) )
  8314. (?<character_class> \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )
  8315. (?<character_type> (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )
  8316. (?<class_item> (?: \[ : (?:
  8317. alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|
  8318. punct|space|upper|word|xdigit
  8319. ) : \] |
  8320. (?&quoted_string) |
  8321. (?&quoted_string_empty) |
  8322. (?&escaped_character) |
  8323. (?&character_type) |
  8324. [^]] ) )
  8325. (?<comment> \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )
  8326. (?<condition> (?: \( [+-]? \d+ \) |
  8327. \( < (?&groupname) > \) |
  8328. \( ' (?&groupname) ' \) |
  8329. \( R \d* \) |
  8330. \( R & (?&groupname) \) |
  8331. \( (?&groupname) \) |
  8332. \( DEFINE \) |
  8333. \( VERSION >?=\d+(?:\.\d\d?)? \) |
  8334. (?&callout)?+ (?&comment)* (?&lookaround) ) )
  8335. (?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )
  8336. (?<delimited_regex> (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex)
  8337. \k'delimiter' .* )
  8338. (?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} |
  8339. x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} |
  8340. [aefnrt] | c[[:print:]] |
  8341. [^[:alnum:]] ) )
  8342. (?<group> (?&capturing_group) | (?&non_capturing_group) |
  8343. (?&resetting_group) | (?&atomic_group) |
  8344. (?&conditional_group) )
  8345. (?<groupname> [a-zA-Z_]\w* )
  8346. (?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )
  8347. (?<lookaround> \(\? (?: = | ! | <= | <! ) (?&regex) \) )
  8348. (?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )
  8349. (?<option_setting> \(\? [iJmnsUx-]* \) )
  8350. (?<qualified_item> (?:\. |
  8351. (?&lookaround) |
  8352. (?&back_reference) |
  8353. (?&character_class) |
  8354. (?&character_type) |
  8355. (?&escaped_character) |
  8356. (?&group) |
  8357. (?&subroutine_call) |
  8358. (?&literal_character) |
  8359. (?&quoted_string)
  8360. ) (?&comment)? (?&qualifier)? )
  8361. (?<qualifier> (?: [?*+] | (?&range_qualifier) ) [+?]? )
  8362. (?<quoted_string> (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) )
  8363. (?<quoted_string_empty> \\Q\\E )
  8364. (?<range_qualifier> \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )
  8365. (?<regex> (?&start_item)* (?&branch) (?: \| (?&branch) )* )
  8366. (?<resetting_group> \( \? \| (?&regex) \) )
  8367. (?<simple_assertion> \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )
  8368. (?<special_escape> \\K )
  8369. (?<start_item> \( \* (?:
  8370. ANY |
  8371. ANYCRLF |
  8372. BSR_ANYCRLF |
  8373. BSR_UNICODE |
  8374. CR |
  8375. CRLF |
  8376. LF |
  8377. LIMIT_MATCH=\d+ |
  8378. LIMIT_DEPTH=\d+ |
  8379. LIMIT_HEAP=\d+ |
  8380. NOTEMPTY |
  8381. NOTEMPTY_ATSTART |
  8382. NO_AUTO_POSSESS |
  8383. NO_DOTSTAR_ANCHOR |
  8384. NO_JIT |
  8385. NO_START_OPT |
  8386. NUL |
  8387. UTF |
  8388. UCP ) \) )
  8389. (?<subroutine_call> (?: \(\?R\) | \(\?[+-]?\d+\) |
  8390. \(\? (?: & | P> ) (?&groupname) \) |
  8391. \\g < (?&groupname) > |
  8392. \\g ' (?&groupname) ' |
  8393. \\g < [+-]? \d+ > |
  8394. \\g ' [+-]? \d+ ) )
  8395. (?<verb> \(\* (?: ACCEPT | FAIL | F | COMMIT |
  8396. (?:MARK)?:(?&verbname) |
  8397. (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )
  8398. (?<verbname> [^)]+ )
  8399. ) # End DEFINE
  8400. # Kick it all off...
  8401. ^(?&delimited_regex)$/subject_literal,jitstack=256
  8402. /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
  8403. 0: /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
  8404. /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
  8405. 0: /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
  8406. /^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]/
  8407. 0: /^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]/
  8408. /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
  8409. 0: /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
  8410. /<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
  8411. 0: /<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
  8412. /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /
  8413. 0: /^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /
  8414. /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  8415. 0: /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
  8416. /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  8417. 0: /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
  8418. /^(\w++|\s++)*$/
  8419. 0: /^(\w++|\s++)*$/
  8420. /a+b?(*THEN)c+(*FAIL)/
  8421. 0: /a+b?(*THEN)c+(*FAIL)/
  8422. /(A (A|B(*ACCEPT)|C) D)(E)/x
  8423. 0: /(A (A|B(*ACCEPT)|C) D)(E)/x
  8424. /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  8425. 0: /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
  8426. /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
  8427. 0: /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
  8428. /(?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
  8429. 0: /(?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
  8430. /(?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)$/
  8431. 0: /(?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)$/
  8432. \= Expect no match
  8433. /((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
  8434. No match
  8435. /(?:(?(2y)a|b)(X))+/
  8436. No match
  8437. /a(*MARK)b/
  8438. No match
  8439. /a(*CR)b/
  8440. No match
  8441. /(?P<abn>(?P=abn)(?<badstufxxx)/
  8442. No match
  8443. # --------------------------------------------------------------------------
  8444. /<(?x:[a b])>/xx
  8445. < >
  8446. 0: < >
  8447. /<(?:[a b])>/xx
  8448. < >
  8449. No match
  8450. /<(?xxx:[a b])>/
  8451. < >
  8452. No match
  8453. /<(?-x:[a b])>/xx
  8454. < >
  8455. 0: < >
  8456. /[[:digit:]-]+/
  8457. 12-24
  8458. 0: 12-24
  8459. /((?<=((*ACCEPT)) )\1?\b) /
  8460. \= Expect no match
  8461. ((?<=((*ACCEPT)) )\\1?\\b)\x20
  8462. No match
  8463. /((?<=((*ACCEPT))X)\1?Y)\1/
  8464. XYYZ
  8465. 0: YY
  8466. 1: Y
  8467. 2:
  8468. /((?<=((*ACCEPT))X)\1?Y(*ACCEPT))\1/
  8469. XYYZ
  8470. 0: Y
  8471. 1: Y
  8472. 2:
  8473. /(?(DEFINE)(?<optional_a>a?)X)^(?&optional_a)a$/
  8474. aa
  8475. 0: aa
  8476. a
  8477. 0: a
  8478. /^(a?)b(?1)a/
  8479. abaa
  8480. 0: abaa
  8481. 1: a
  8482. aba
  8483. 0: aba
  8484. 1: a
  8485. baa
  8486. 0: baa
  8487. 1:
  8488. ba
  8489. 0: ba
  8490. 1:
  8491. /^(a?)+b(?1)a/
  8492. abaa
  8493. 0: abaa
  8494. 1:
  8495. aba
  8496. 0: aba
  8497. 1:
  8498. baa
  8499. 0: baa
  8500. 1:
  8501. ba
  8502. 0: ba
  8503. 1:
  8504. /^(a?)++b(?1)a/
  8505. abaa
  8506. 0: abaa
  8507. 1:
  8508. aba
  8509. 0: aba
  8510. 1:
  8511. baa
  8512. 0: baa
  8513. 1:
  8514. ba
  8515. 0: ba
  8516. 1:
  8517. /^(a?)+b/
  8518. b
  8519. 0: b
  8520. 1:
  8521. ab
  8522. 0: ab
  8523. 1:
  8524. aaab
  8525. 0: aaab
  8526. 1:
  8527. /(?=a+)a(a+)++b/
  8528. aab
  8529. 0: aab
  8530. 1: a
  8531. /(?<=\G.)/g,aftertext
  8532. abc
  8533. 0:
  8534. 0+ bc
  8535. 0:
  8536. 0+ c
  8537. 0:
  8538. 0+
  8539. /(?<=(?=.)?)/
  8540. /(?<=(?=.)?+)/
  8541. /(?<=(?=.)*)/
  8542. /(?<=(?=.){4,5})/
  8543. /(?<=(?=.){4,5}x)/
  8544. /a(?=.(*:X))(*SKIP:X)(*F)|(.)/
  8545. abc
  8546. 0: a
  8547. 1: a
  8548. /a(?>(*:X))(*SKIP:X)(*F)|(.)/
  8549. abc
  8550. 0: a
  8551. 1: a
  8552. /a(?:(*:X))(*SKIP:X)(*F)|(.)/
  8553. abc
  8554. 0: b
  8555. 1: b
  8556. #pattern no_start_optimize
  8557. /(?>a(*:1))(?>b(*:1))(*SKIP:1)x|.*/
  8558. abc
  8559. 0: abc
  8560. /(?>a(*:1))(?>b)(*SKIP:1)x|.*/
  8561. abc
  8562. 0: abc
  8563. #subject mark
  8564. /a(*ACCEPT:X)b/
  8565. abc
  8566. 0: a
  8567. MK: X
  8568. /(?=a(*ACCEPT:QQ)bc)axyz/
  8569. axyz
  8570. 0: axyz
  8571. MK: QQ
  8572. /(?(DEFINE)(a(*ACCEPT:X)))(?1)b/
  8573. abc
  8574. 0: ab
  8575. MK: X
  8576. /a(*F:X)b/
  8577. abc
  8578. No match, mark = X
  8579. /(?(DEFINE)(a(*F:X)))(?1)b/
  8580. abc
  8581. No match, mark = X
  8582. /a(*COMMIT:X)b/
  8583. abc
  8584. 0: ab
  8585. MK: X
  8586. /(?(DEFINE)(a(*COMMIT:X)))(?1)b/
  8587. abc
  8588. 0: ab
  8589. MK: X
  8590. /a+(*:Z)b(*COMMIT:X)(*SKIP:Z)c|.*/
  8591. aaaabd
  8592. 0: bd
  8593. /a+(*:Z)b(*COMMIT:X)(*SKIP:X)c|.*/
  8594. aaaabd
  8595. No match, mark = X
  8596. /a(*COMMIT:X)b/
  8597. axabc
  8598. No match, mark = X
  8599. #pattern -no_start_optimize
  8600. #subject -mark
  8601. /(.COMMIT)(*COMMIT::::::::::interal error:::)/
  8602. /(*COMMIT:ÿÿ)/
  8603. /(*COMMIT:]w)/
  8604. /(?i)A(?^)B(?^x:C D)(?^i)e f/
  8605. aBCDE F
  8606. 0: aBCDE F
  8607. \= Expect no match
  8608. aBCDEF
  8609. No match
  8610. AbCDe f
  8611. No match
  8612. /(*pla:foo).{6}/
  8613. abcfoobarxyz
  8614. 0: foobar
  8615. \= Expect no match
  8616. abcfooba
  8617. No match
  8618. /(*positive_lookahead:foo).{6}/
  8619. abcfoobarxyz
  8620. 0: foobar
  8621. /(?(*pla:foo).{6}|a..)/
  8622. foobarbaz
  8623. 0: foobar
  8624. abcfoobar
  8625. 0: abc
  8626. /(?(*positive_lookahead:foo).{6}|a..)/
  8627. foobarbaz
  8628. 0: foobar
  8629. abcfoobar
  8630. 0: abc
  8631. /(*plb:foo)bar/
  8632. abcfoobar
  8633. 0: bar
  8634. \= Expect no match
  8635. abcbarfoo
  8636. No match
  8637. /(*positive_lookbehind:foo)bar/
  8638. abcfoobar
  8639. 0: bar
  8640. \= Expect no match
  8641. abcbarfoo
  8642. No match
  8643. /(?(*plb:foo)bar|baz)/
  8644. abcfoobar
  8645. 0: bar
  8646. bazfoobar
  8647. 0: baz
  8648. abcbazfoobar
  8649. 0: baz
  8650. foobazfoobar
  8651. 0: bar
  8652. /(?(*positive_lookbehind:foo)bar|baz)/
  8653. abcfoobar
  8654. 0: bar
  8655. bazfoobar
  8656. 0: baz
  8657. abcbazfoobar
  8658. 0: baz
  8659. foobazfoobar
  8660. 0: bar
  8661. /(*nlb:foo)bar/
  8662. abcbarfoo
  8663. 0: bar
  8664. \= Expect no match
  8665. abcfoobar
  8666. No match
  8667. /(*negative_lookbehind:foo)bar/
  8668. abcbarfoo
  8669. 0: bar
  8670. \= Expect no match
  8671. abcfoobar
  8672. No match
  8673. /(?(*nlb:foo)bar|baz)/
  8674. abcfoobaz
  8675. 0: baz
  8676. abcbarbaz
  8677. 0: bar
  8678. \= Expect no match
  8679. abcfoobar
  8680. No match
  8681. /(?(*negative_lookbehind:foo)bar|baz)/
  8682. abcfoobaz
  8683. 0: baz
  8684. abcbarbaz
  8685. 0: bar
  8686. \= Expect no match
  8687. abcfoobar
  8688. No match
  8689. /(*atomic:a+)\w/
  8690. aaab
  8691. 0: aaab
  8692. \= Expect no match
  8693. aaaa
  8694. No match
  8695. / (?<word> \w+ )* \. /xi
  8696. pokus.
  8697. 0: pokus.
  8698. 1: pokus
  8699. /(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
  8700. pokus.
  8701. 0: pokus.
  8702. /(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
  8703. pokus.
  8704. 0: pokus.
  8705. 1: <unset>
  8706. 2: pokus
  8707. /(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
  8708. pokus.
  8709. 0: pokus.
  8710. /(?&word)* \. (?<word> \w+ )/xi
  8711. pokus.hokus
  8712. 0: pokus.hokus
  8713. 1: hokus
  8714. /a(?(?=(*:2)b).)/mark
  8715. abc
  8716. 0: ab
  8717. MK: 2
  8718. acb
  8719. 0: a
  8720. /a(?(?!(*:2)b).)/mark
  8721. acb
  8722. 0: ac
  8723. abc
  8724. 0: a
  8725. MK: 2
  8726. /(?:a|ab){1}+c/
  8727. \= Expect no match
  8728. abc
  8729. No match
  8730. /(a|ab){1}+c/
  8731. abc
  8732. No match
  8733. /(a+){1}+a/
  8734. \= Expect no match
  8735. aaaa
  8736. No match
  8737. /(?(DEFINE)(a|ab))(?1){1}+c/
  8738. abc
  8739. No match
  8740. /(?:a|(?=b)|.)*\z/
  8741. abc
  8742. 0: abc
  8743. /(?:a|(?=b)|.)*/
  8744. abc
  8745. 0: a
  8746. /(?<=a(*SKIP)x)|c/
  8747. abcd
  8748. No match
  8749. /(?<=a(*SKIP)x)|d/
  8750. abcd
  8751. 0: d
  8752. /(?<=(?=.(?<=x)))/aftertext
  8753. abx
  8754. 0:
  8755. 0+ x
  8756. /(?<=(?=(?<=a)))b/
  8757. ab
  8758. 0: b
  8759. /^(?<A>a)(?(<A>)b)((?<=b).*)$/
  8760. abc
  8761. 0: abc
  8762. 1: a
  8763. 2: c
  8764. /^(a\1?){4}$/
  8765. aaaa
  8766. 0: aaaa
  8767. 1: a
  8768. aaaaaa
  8769. 0: aaaaaa
  8770. 1: aa
  8771. /^((\1+)|\d)+133X$/
  8772. 111133X
  8773. 0: 111133X
  8774. 1: 11
  8775. 2: 11
  8776. /^(?>.*?([A-Z])(?!.*\1)){26}/i
  8777. The quick brown fox jumps over the lazy dog.
  8778. 0: The quick brown fox jumps over the lazy dog
  8779. 1: g
  8780. Jackdaws love my big sphinx of quartz.
  8781. 0: Jackdaws love my big sphinx of quartz
  8782. 1: z
  8783. Pack my box with five dozen liquor jugs.
  8784. 0: Pack my box with five dozen liquor jugs
  8785. 1: s
  8786. \= Expect no match
  8787. The quick brown fox jumps over the lazy cat.
  8788. No match
  8789. Hackdaws love my big sphinx of quartz.
  8790. No match
  8791. Pack my fox with five dozen liquor jugs.
  8792. No match
  8793. /(?<=X(?(DEFINE)(A)))X(*F)/
  8794. \= Expect no match
  8795. AXYZ
  8796. No match
  8797. /(?<=X(?(DEFINE)(A)))./
  8798. AXYZ
  8799. 0: Y
  8800. /(?<=X(?(DEFINE)(.*))Y)./
  8801. AXYZ
  8802. 0: Z
  8803. /(?<=X(?(DEFINE)(Y))(?1))./
  8804. AXYZ
  8805. 0: Z
  8806. /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/
  8807. word
  8808. 0: word
  8809. /a{1,2,3}b/
  8810. a{1,2,3}b
  8811. 0: a{1,2,3}b
  8812. /\214748364/
  8813. >\x{8c}748364<
  8814. 0: \x8c748364
  8815. /a{65536/
  8816. >a{65536<
  8817. 0: a{65536
  8818. /a\K.(?0)*/
  8819. abac
  8820. 0: c
  8821. /(a\K.(?1)*)/
  8822. abac
  8823. 0: c
  8824. 1: abac
  8825. # --------------------------------------------------------------------------
  8826. # Perl-compatible tests of variable-length lookbehinds.
  8827. /(?<=ab?c).../g
  8828. abcdefgacxyz
  8829. 0: def
  8830. 0: xyz
  8831. /(?<=PQR|ab?c).../g
  8832. abcdefgacxyzPQR123
  8833. 0: def
  8834. 0: xyz
  8835. 0: 123
  8836. /(?<=ab?c|PQR).../g
  8837. abcdefgacxyzPQR123
  8838. 0: def
  8839. 0: xyz
  8840. 0: 123
  8841. /(?<=PQ|ab?c).../g
  8842. abcdefgacxyzPQR123
  8843. 0: def
  8844. 0: xyz
  8845. 0: R12
  8846. /(?<=ab?c|PQ).../g
  8847. abcdefgacxyzPQR123
  8848. 0: def
  8849. 0: xyz
  8850. 0: R12
  8851. /(?<=a(b?c|d?e?e)f)X./g
  8852. acfX1zzzaefX2zzzadeefX3zzzX4zzz
  8853. 0: X1
  8854. 1: c
  8855. 0: X2
  8856. 1: e
  8857. 0: X3
  8858. 1: dee
  8859. /(?<!a(b?c|d?e?e)f)X./g
  8860. acfX1zzzaefX2zzzadeefX3zzzX4zzz
  8861. 0: X4
  8862. /(?(?<=ab?c)d|e)/
  8863. abcdefg
  8864. 0: d
  8865. acdefg
  8866. 0: d
  8867. axdefg
  8868. 0: e
  8869. /(?<=\d{2,3}|ABC)./
  8870. ABCD
  8871. 0: D
  8872. /(?<=(\d{1,255}))X/
  8873. 1234X
  8874. 0: X
  8875. 1: 1234
  8876. /(?<=a(b?c){3}d)X/
  8877. ZXacbccdXYZ
  8878. 0: X
  8879. 1: c
  8880. /(?<=a(b?c){0}d)X/
  8881. ZXadXYZ
  8882. 0: X
  8883. /(?<=a?(b?c){0}d)X./
  8884. ZXadXYZ
  8885. 0: XY
  8886. /(?<=\R)X/
  8887. \x{0a}X
  8888. 0: X
  8889. a\x{0a}X
  8890. 0: X
  8891. a\x{0d}\x{0a}X
  8892. 0: X
  8893. # --------------------------------------------------------------------------
  8894. # Altered interpretation of {,n}
  8895. /a{,3}B/
  8896. XBBB
  8897. 0: B
  8898. XaBBB
  8899. 0: aB
  8900. XaaBBB
  8901. 0: aaB
  8902. XaaaBBB
  8903. 0: aaaB
  8904. XaaaaBBB
  8905. 0: aaaB
  8906. # But {,} remains not a qualifier
  8907. /a{,}B/
  8908. Xa{,}BBB
  8909. 0: a{,}B
  8910. \= Expect no match
  8911. XBBB
  8912. No match
  8913. XaBBB
  8914. No match
  8915. # Checks for non-quantifiers after refactored code
  8916. /X{/
  8917. ZZX{}YY
  8918. 0: X{
  8919. /X{A/
  8920. ZZX{ABC}
  8921. 0: X{A
  8922. /X{}/
  8923. ZZX{}YZ
  8924. 0: X{}
  8925. /X{1234/
  8926. ZZX{123456
  8927. 0: X{1234
  8928. /X{12ABC}/
  8929. ZZX{12ABC}Y
  8930. 0: X{12ABC}
  8931. /X{1,/
  8932. ZZX{1,...
  8933. 0: X{1,
  8934. /X{,9/
  8935. ZZX{,9}abc
  8936. 0: X{,9
  8937. /X{,9]/
  8938. ZZX{,9]..
  8939. 0: X{,9]
  8940. # --------------------------------------------------------------------------
  8941. /(A)(?-1)(?+1)(B)/
  8942. xxAABBzz
  8943. 0: AABB
  8944. 1: A
  8945. 2: B
  8946. /(A)(\g{ -2 }B)/
  8947. XAABX
  8948. 0: AAB
  8949. 1: A
  8950. 2: AB
  8951. /(A)((?-2)B)/
  8952. XAABX
  8953. 0: AAB
  8954. 1: A
  8955. 2: AB
  8956. /a\c\X/
  8957. --a\x1cX--
  8958. 0: a\x1cX
  8959. /(a)\g{ 1 }/
  8960. baab
  8961. 0: aa
  8962. 1: a
  8963. /a{ 1,2 }/
  8964. Xaaaaa
  8965. 0: aa
  8966. /a{ 1 , 2 }/
  8967. Xaaaaa
  8968. 0: aa
  8969. /(?'name'ab)\k{ name }(?P=name)/
  8970. XabababX
  8971. 0: ababab
  8972. 1: ab
  8973. /A{,}B/
  8974. A{,}B
  8975. 0: A{,}B
  8976. /A{ , }B/
  8977. A{ , }B
  8978. 0: A{ , }B
  8979. /A{ ,3}/
  8980. AAAAAACC
  8981. 0: AAA
  8982. /A{ 3, }/
  8983. BBAAAAAACC
  8984. 0: AAAAAA
  8985. # This pattern validates regular expression patterns. The original that I was
  8986. # sent was this:
  8987. # /^((?:(?:[^?+*{}()[\]\\|]+|\\.|\[(?:\^?\\.|\^[^\\]|[^\\^])(?:[^\]\\]+|\\.)*\]|\((?:\?[:=!]|\?<[=!]|\?>)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)$/
  8988. # This is not very readable, and also does not handle all features. I have done
  8989. # some work on it.
  8990. /^
  8991. (?<re>
  8992. # A regular expression is zero or more of these items.
  8993. (?:
  8994. # An item is one of these:
  8995. (?:
  8996. [^?+*{}()\[\]\\|]++| # Non-meta characters or unquoted .
  8997. \\.| # Quoted .
  8998. \[ # Class, which is [
  8999. (?: # Followed by
  9000. \^?\\.| # Optional ^ and any escaped character
  9001. \^[^\\]| # OR ^ and not escaped character
  9002. [^\\^] # OR neither ^ nor \
  9003. ) # Followed by
  9004. (?:[^\]\\]+|\\.)*+ # Zero or more (not ] or \) OR escaped dot
  9005. \]| # Class ends with ]
  9006. \( # Parenthesized group
  9007. (?: # Start with optional
  9008. \?[:=!]| # ? followed by : = !
  9009. \?<[=!]| # OR ?< followed by = or !
  9010. \?> # OR ?>
  9011. )?
  9012. (?&re)?? # Then a nested <re>
  9013. \)| # End parenthesized group
  9014. \(\? # Other parenthesized items
  9015. (?: # (? followed by
  9016. R| # R
  9017. [+-]?\d++ # Or optional +- and digits
  9018. )
  9019. \)| # End parens
  9020. \(\* # Verbs
  9021. (?:
  9022. COMMIT|
  9023. FAIL|
  9024. MARK:[^)]*|
  9025. (?:PRUNE|SKIP|THEN)(?::[^\)]*+)?
  9026. )
  9027. \)
  9028. ) # End list of items
  9029. # Followed by an optional quantifier
  9030. (?:
  9031. (?:
  9032. [?+*] # ?+*
  9033. | # OR
  9034. \{\d+ # { digits
  9035. (?:,\d*)? # optionally followed by ,digits
  9036. \} # then closing }
  9037. | # OR
  9038. \{,\d+} # {,digits}
  9039. )
  9040. [?+]? # optional ungreedy or possessive
  9041. )?
  9042. | # OR an "item" is a branch ending
  9043. \|
  9044. )* # Zero or more top-level items.
  9045. ) # End regex group.
  9046. $/x
  9047. [abcdef]
  9048. 0: [abcdef]
  9049. 1: [abcdef]
  9050. [abc\\]def]
  9051. 0: [abc\]def]
  9052. 1: [abc\]def]
  9053. a.b|abcd
  9054. 0: a.b|abcd
  9055. 1: a.b|abcd
  9056. ab()d
  9057. 0: ab()d
  9058. 1: ab()d
  9059. ab{1,3}d
  9060. 0: ab{1,3}d
  9061. 1: ab{1,3}d
  9062. ab{,3}d
  9063. 0: ab{,3}d
  9064. 1: ab{,3}d
  9065. ab(*FAIL)d(*COMMIT)(*SKIP)(*THEN:abc)
  9066. 0: ab(*FAIL)d(*COMMIT)(*SKIP)(*THEN:abc)
  9067. 1: ab(*FAIL)d(*COMMIT)(*SKIP)(*THEN:abc)
  9068. ab(*MARK:xyz)
  9069. 0: ab(*MARK:xyz)
  9070. 1: ab(*MARK:xyz)
  9071. (?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\\s])
  9072. 0: (?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])
  9073. 1: (?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])
  9074. abcd\\t\\n\\r\\f\\a\\e\\071\\x3b\\^\\\\\\?caxyz
  9075. 0: abcd\t\n\r\f\a\e\071\x3b\^\\\?caxyz
  9076. 1: abcd\t\n\r\f\a\e\071\x3b\^\\\?caxyz
  9077. a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz
  9078. 0: a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz
  9079. 1: a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz
  9080. \\G(?:(?=(\\1.|)(.))){1,13}?(?!.*\\2.*\\2)\\1\\K\\2
  9081. 0: \G(?:(?=(\1.|)(.))){1,13}?(?!.*\2.*\2)\1\K\2
  9082. 1: \G(?:(?=(\1.|)(.))){1,13}?(?!.*\2.*\2)\1\K\2
  9083. \= Expect no match
  9084. ab)d
  9085. No match
  9086. ab(d
  9087. No match
  9088. {4,5}
  9089. No match
  9090. a[]b
  9091. No match
  9092. (a)(?(1)a|b|c)
  9093. No match
  9094. /^..A(*SKIP)B|C/
  9095. 12ADC
  9096. 0: C
  9097. /(?<!a?)/
  9098. a
  9099. No match
  9100. # End of testinput1