# This set of tests is for features that are compatible with all versions of # Perl >= 5.10, in non-UTF mode. It should run clean for the 8-bit, 16-bit, and # 32-bit PCRE libraries, and also using the perltest.sh script. # WARNING: Use only / as the pattern delimiter. Although pcre2test supports # a number of delimiters, all those other than / give problems with the # perltest.sh script. #forbid_utf #newline_default lf any anycrlf #perltest /the quick brown fox/ the quick brown fox What do you know about the quick brown fox? \= Expect no match The quick brown FOX What do you know about THE QUICK BROWN FOX? /The quick brown fox/i the quick brown fox The quick brown FOX What do you know about the quick brown fox? What do you know about THE QUICK BROWN FOX? /abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/ abcd\t\n\r\f\a\e9;\$\\?caxyz /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/ abxyzpqrrrabbxyyyypqAzz abxyzpqrrrabbxyyyypqAzz aabxyzpqrrrabbxyyyypqAzz aaabxyzpqrrrabbxyyyypqAzz aaaabxyzpqrrrabbxyyyypqAzz abcxyzpqrrrabbxyyyypqAzz aabcxyzpqrrrabbxyyyypqAzz aaabcxyzpqrrrabbxyyyypAzz aaabcxyzpqrrrabbxyyyypqAzz aaabcxyzpqrrrabbxyyyypqqAzz aaabcxyzpqrrrabbxyyyypqqqAzz aaabcxyzpqrrrabbxyyyypqqqqAzz aaabcxyzpqrrrabbxyyyypqqqqqAzz aaabcxyzpqrrrabbxyyyypqqqqqqAzz aaaabcxyzpqrrrabbxyyyypqAzz abxyzzpqrrrabbxyyyypqAzz aabxyzzzpqrrrabbxyyyypqAzz aaabxyzzzzpqrrrabbxyyyypqAzz aaaabxyzzzzpqrrrabbxyyyypqAzz abcxyzzpqrrrabbxyyyypqAzz aabcxyzzzpqrrrabbxyyyypqAzz aaabcxyzzzzpqrrrabbxyyyypqAzz aaaabcxyzzzzpqrrrabbxyyyypqAzz aaaabcxyzzzzpqrrrabbbxyyyypqAzz aaaabcxyzzzzpqrrrabbbxyyyyypqAzz aaabcxyzpqrrrabbxyyyypABzz aaabcxyzpqrrrabbxyyyypABBzz >>>aaabxyzpqrrrabbxyyyypqAzz >aaaabxyzpqrrrabbxyyyypqAzz >>>>abcxyzpqrrrabbxyyyypqAzz \= Expect no match abxyzpqrrabbxyyyypqAzz abxyzpqrrrrabbxyyyypqAzz abxyzpqrrrabxyyyypqAzz aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz aaaabcxyzzzzpqrrrabbbxyyypqAzz aaabcxyzpqrrrabbxyyyypqqqqqqqAzz /^(abc){1,2}zz/ abczz abcabczz \= Expect no match zz abcabcabczz >>abczz /^(b+?|a){1,2}?c/ bc bbc bbbc bac bbac aac abbbbbbbbbbbc bbbbbbbbbbbac \= Expect no match aaac abbbbbbbbbbbac /^(b+|a){1,2}c/ bc bbc bbbc bac bbac aac abbbbbbbbbbbc bbbbbbbbbbbac \= Expect no match aaac abbbbbbbbbbbac /^(ba|b*){1,2}?bc/ babc bbabc bababc \= Expect no match bababbc babababc /^\ca\cA\c[;\c:/ \x01\x01\e;z /^[ab\]cde]/ athing bthing ]thing cthing dthing ething \= Expect no match fthing [thing \\thing /^[]cde]/ ]thing cthing dthing ething \= Expect no match athing fthing /^[^ab\]cde]/ fthing [thing \\thing \= Expect no match athing bthing ]thing cthing dthing ething /^[^]cde]/ athing fthing \= Expect no match ]thing cthing dthing ething /^\/ /^/ /^[0-9]+$/ 0 1 2 3 4 5 6 7 8 9 10 100 \= Expect no match abc /^.*nter/ enter inter uponter /^xxx[0-9]+$/ xxx0 xxx1234 \= Expect no match xxx /^.+[0-9][0-9][0-9]$/ x123 x1234 xx123 123456 \= Expect no match 123 /^.+?[0-9][0-9][0-9]$/ x123 x1234 xx123 123456 \= Expect no match 123 /^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/ abc!pqr=apquxz.ixr.zzz.ac.uk \= Expect no match !pqr=apquxz.ixr.zzz.ac.uk abc!=apquxz.ixr.zzz.ac.uk abc!pqr=apquxz:ixr.zzz.ac.uk abc!pqr=apquxz.ixr.zzz.ac.ukk /:/ Well, we need a colon: somewhere \= Expect no match Fail without a colon /([\da-f:]+)$/i 0abc abc fed E :: 5f03:12C0::932e fed def Any old stuff \= Expect no match 0zzz gzzz fed\x20 Any old rubbish /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ .1.2.3 A.12.123.0 \= Expect no match .1.2.3333 1.2.3 1234.2.3 /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/ 1 IN SOA non-sp1 non-sp2( 1 IN SOA non-sp1 non-sp2 ( \= Expect no match 1IN SOA non-sp1 non-sp2( /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/ a. Z. 2. ab-c.pq-r. sxk.zzz.ac.uk. x-.y-. \= Expect no match -abc.peq. /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/ *.a *.b0-a *.c3-b.c *.c-a.b-c \= Expect no match *.0 *.a- *.a-b.c- *.c-a.0-c /^(?=ab(de))(abd)(e)/ abde /^(?!(ab)de|x)(abd)(f)/ abdf /^(?=(ab(cd)))(ab)/ abcd /^[\da-f](\.[\da-f])*$/i a.b.c.d A.B.C.D a.b.c.1.2.3.C /^\".*\"\s*(;.*)?$/ \"1234\" \"abcd\" ; \"\" ; rhubarb \= Expect no match \"1234\" : things /^$/ \ \= Expect no match A non-empty line / ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x ab c \= Expect no match abc ab cde /(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/ ab c \= Expect no match abc ab cde /^ a\ b[c ]d $/x a bcd a b d \= Expect no match abcd ab d /^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/ abcdefhijklm /^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/ abcdefhijklm /^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/ a+ Z0+\x08\n\x1d\x12 /^[.^$|()*+?{,}]+/ .^\$(*+)|{?,?} /^a*\w/ z az aaaz a aa aaaa a+ aa+ /^a*?\w/ z az aaaz a aa aaaa a+ aa+ /^a+\w/ az aaaz aa aaaa aa+ /^a+?\w/ az aaaz aa aaaa aa+ /^\d{8}\w{2,}/ 1234567890 12345678ab 12345678__ \= Expect no match 1234567 /^[aeiou\d]{4,5}$/ uoie 1234 12345 aaaaa \= Expect no match 123456 /^[aeiou\d]{4,5}?/ uoie 1234 12345 aaaaa 123456 /\A(abc|def)=(\1){2,3}\Z/ abc=abcabc def=defdefdef \= Expect no match abc=defdef /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/ abcdefghijkcda2 abcdefghijkkkkcda2 /(cat(a(ract|tonic)|erpillar)) \1()2(3)/ cataract cataract23 catatonic catatonic23 caterpillar caterpillar23 /^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]/ From abcd Mon Sep 01 12:33:02 1997 /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/ From abcd Mon Sep 01 12:33:02 1997 From abcd Mon Sep 1 12:33:02 1997 \= Expect no match From abcd Sep 01 12:33:02 1997 /^12.34/s 12\n34 12\r34 /\w+(?=\t)/ the quick brown\t fox /foo(?!bar)(.*)/ foobar is foolish see? /(?:(?!foo)...|^.{0,2})bar(.*)/ foobar crowbar etc barrel 2barrel A barrel /^(\D*)(?=\d)(?!123)/ abc456 \= Expect no match abc123 /^1234(?# test newlines inside)/ 1234 /^1234 #comment in extended re /x 1234 /#rhubarb abcd/x abcd /^abcd#rhubarb/x abcd /^(a)\1{2,3}(.)/ aaab aaaab aaaaab aaaaaab /(?!^)abc/ the abc \= Expect no match abc /(?=^)abc/ abc \= Expect no match the abc /^[ab]{1,3}(ab*|b)/ aabbbbb /^[ab]{1,3}?(ab*|b)/ aabbbbb /^[ab]{1,3}?(ab*?|b)/ aabbbbb /^[ab]{1,3}(ab*?|b)/ aabbbbb / (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* # optional leading comment (?: (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote ) # initial word (?: (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote ) )* # further okay, if led by a period (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* @ (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # initial subdomain (?: # (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. # if led by a period... (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # ...further okay )* # address | # or (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote ) # one word, optionally followed by.... (?: [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or... \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) | # comments, or... " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote # quoted strings )* < (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* # leading < (?: @ (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # initial subdomain (?: # (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. # if led by a period... (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # ...further okay )* (?: (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* , (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* @ (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # initial subdomain (?: # (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. # if led by a period... (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # ...further okay )* )* # further okay, if led by comma : # closing colon (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* )? # optional route (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote ) # initial word (?: (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | " (?: # opening quote... [^\\\x80-\xff\n\015"] # Anything except backslash and quote | # or \\ [^\x80-\xff] # Escaped something (something != CR) )* " # closing quote ) )* # further okay, if led by a period (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* @ (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # initial subdomain (?: # (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* \. # if led by a period... (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) # ...further okay )* # address spec (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* > # trailing > # name and address ) (?: [\040\t] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )* \) )* # optional trailing comment /x Alan Other user\@dom.ain \"A. Other\" (a comment) A. Other (a comment) \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay A missing angle @,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom # Atom | # or " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " # Quoted string ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom # Atom | # or " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " # Quoted string ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # additional words )* @ [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments )* # address | # or (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom # Atom | # or " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " # Quoted string ) # leading word [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces (?: (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) | " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " ) # "special" comment or quoted string [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal" )* < [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # < (?: @ [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments )* (?: , [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. @ [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments )* )* # additional domains : [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments )? # optional route (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom # Atom | # or " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " # Quoted string ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom # Atom | # or " # " [^\\\x80-\xff\n\015"] * # normal (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )* " # " # Quoted string ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # additional words )* @ [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments (?: \. [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. (?: [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters... (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom | \[ # [ (?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff \] # ] ) [\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. # optional trailing comments )* # address spec > # > # name and address ) /x Alan Other user\@dom.ain \"A. Other\" (a comment) A. Other (a comment) \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay A missing angle ]{0,})>]{0,})>([\d]{0,}\.)(.*)((
([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is 43.Word Processor
(N-1286)
Lega lstaff.comCA - Statewide /a[^a]b/ acb a\nb /a.b/ acb \= Expect no match a\nb /a[^a]b/s acb a\nb /a.b/s acb a\nb /^(b+?|a){1,2}?c/ bac bbac bbbac bbbbac bbbbbac /^(b+|a){1,2}?c/ bac bbac bbbac bbbbac bbbbbac /(?!\A)x/m a\bx\n a\nx\n \= Expect no match x\nb\n /(A|B)*?CD/ CD /(A|B)*CD/ CD /(AB)*?\1/ ABABAB /(AB)*\1/ ABABAB /(?.*\/)foo/ /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo \= Expect no match /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/ /(?>(\.\d\d[1-9]?))\d+/ 1.230003938 1.875000282 \= Expect no match 1.235 /^((?>\w+)|(?>\s+))*$/ now is the time for all good men to come to the aid of the party \= Expect no match this is not a line with only words and spaces! /(\d+)(\w)/ 12345a 12345+ /((?>\d+))(\w)/ 12345a \= Expect no match 12345+ /(?>a+)b/ aaab /((?>a+)b)/ aaab /(?>(a+))b/ aaab /(?>b)+/ aaabbbccc /(?>a+|b+|c+)*c/ aaabbbbccccd /((?>[^()]+)|\([^()]*\))+/ ((abc(ade)ufh()()x /\(((?>[^()]+)|\([^()]+\))+\)/ (abc) (abc(def)xyz) \= Expect no match ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /a(?-i)b/i ab Ab \= Expect no match aB AB /(a (?x)b c)d e/ a bcd e \= Expect no match a b cd e abcd e a bcde /(a b(?x)c d (?-x)e f)/ a bcde f \= Expect no match abcdef /(a(?i)b)c/ abc aBc \= Expect no match abC aBC Abc ABc ABC AbC /a(?i:b)c/ abc aBc \= Expect no match ABC abC aBC /a(?i:b)*c/ aBc aBBc \= Expect no match aBC aBBC /a(?=b(?i)c)\w\wd/ abcd abCd \= Expect no match aBCd abcD /(?s-i:more.*than).*million/i more than million more than MILLION more \n than Million \= Expect no match MORE THAN MILLION more \n than \n million /(?:(?s-i)more.*than).*million/i more than million more than MILLION more \n than Million \= Expect no match MORE THAN MILLION more \n than \n million /(?>a(?i)b+)+c/ abc aBbc aBBc \= Expect no match Abc abAb abbC /(?=a(?i)b)\w\wc/ abc aBc \= Expect no match Ab abC aBC /(?<=a(?i)b)(\w\w)c/ abxxc aBxxc \= Expect no match Abxxc ABxxc abxxC /(?:(a)|b)(?(1)A|B)/ aA bB \= Expect no match aB bA /^(a)?(?(1)a|b)+$/ aa b bb \= Expect no match ab # Perl gets this next one wrong if the pattern ends with $; in that case it # fails to match "12". /^(?(?=abc)\w{3}:|\d\d)/ abc: 12 123 \= Expect no match xyz /^(?(?!abc)\d\d|\w{3}:)$/ abc: 12 \= Expect no match 123 xyz /(?(?<=foo)bar|cat)/ foobar cat fcat focat \= Expect no match foocat /(?(?a*)*/ a aa aaaa /(abc|)+/ abc abcabc abcabcabc xyz /([a]*)*/ a aaaaa /([ab]*)*/ a b ababab aaaabcde bbbb /([^a]*)*/ b bbbb aaa /([^ab]*)*/ cccc abab /([a]*?)*/ a aaaa /([ab]*?)*/ a b abab baba /([^a]*?)*/ b bbbb aaa /([^ab]*?)*/ c cccc baba /(?>a*)*/ a aaabcde /((?>a*))*/ aaaaa aabbaa /((?>a*?))*/ aaaaa aabbaa /(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x 12-sep-98 12-09-98 \= Expect no match sep-12-98 /(?<=(foo))bar\1/ foobarfoo foobarfootling \= Expect no match foobar barfoo /(?i:saturday|sunday)/ saturday sunday Saturday Sunday SATURDAY SUNDAY SunDay /(a(?i)bc|BB)x/ abcx aBCx bbx BBx \= Expect no match abcX aBCX bbX BBX /^([ab](?i)[cd]|[ef])/ ac aC bD elephant Europe frog France \= Expect no match Africa /^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/ ab aBd xy xY zebra Zambesi \= Expect no match aCD XY /(?<=foo\n)^bar/m foo\nbar \= Expect no match bar baz\nbar /(?<=(?]&/ <&OUT /^(a\1?){4}$/ aaaaaaaaaa \= Expect no match AB aaaaaaaaa aaaaaaaaaaa /^(a(?(1)\1)){4}$/ aaaaaaaaaa \= Expect no match aaaaaaaaa aaaaaaaaaaa /(?<=a)b/ ab \= Expect no match cb b /(?a+)ab/ /(?>a+)b/ aaab /([[:]+)/ a:[b]: /([[=]+)/ a=[b]= /([[.]+)/ a.[b]. /((?>a+)b)/ aaab /(?>(a+))b/ aaab /((?>[^()]+)|\([^()]*\))+/ ((abc(ade)ufh()()x /a\Z/ \= Expect no match aaab a\nb\n /b\Z/ a\nb\n /b\z/ /b\Z/ a\nb /b\z/ a\nb /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/ a abc a-b 0-9 a.b 5.6.7 the.quick.brown.fox a100.b200.300c 12-ab.1245 \= Expect no match \ .a -a a- a. a_b a.- a.. ab..bc the.quick.brown.fox- the.quick.brown.fox. the.quick.brown.fox_ the.quick.brown.fox+ /(?>.*)(?<=(abcd|wxyz))/ alphabetabcd endingwxyz \= Expect no match a rather long string that doesn't end with one of them /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/ word cat dog elephant mussel cow horse canary baboon snake shark otherword \= Expect no match word cat dog elephant mussel cow horse canary baboon snake shark /word (?>[a-zA-Z0-9]+ ){0,30}otherword/ \= Expect no match 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 /(?<=\d{3}(?!999))foo/ 999foo 123999foo \= Expect no match 123abcfoo /(?<=(?!...999)\d{3})foo/ 999foo 123999foo \= Expect no match 123abcfoo /(?<=\d{3}(?!999)...)foo/ 123abcfoo 123456foo \= Expect no match 123999foo /(?<=\d{3}...)(?\s*)=(?>\s*) # find Z)+|A)*/ ZABCDEFG /((?>)+|A)*/ ZABCDEFG /a*/g abbab /[[:space:]]+/ > \x09\x0a\x0c\x0d\x0b< /[[:blank:]]+/ > \x09\x0a\x0c\x0d\x0b< /[\s]+/ > \x09\x0a\x0c\x0d\x0b< /\s+/ > \x09\x0a\x0c\x0d\x0b< /a b/x ab /(?!\A)x/m a\nxb\n /(?!^)x/m \= Expect no match a\nxb\n /abc\Qabc\Eabc/ abcabcabc /abc\Q(*+|\Eabc/ abc(*+|abc / abc\Q abc\Eabc/x abc abcabc \= Expect no match abcabcabc /abc#comment \Q#not comment literal\E/x abc#not comment\n literal /abc#comment \Q#not comment literal/x abc#not comment\n literal /abc#comment \Q#not comment literal\E #more comment /x abc#not comment\n literal /abc#comment \Q#not comment literal\E #more comment/x abc#not comment\n literal /\Qabc\$xyz\E/ abc\\\$xyz /\Qabc\E\$\Qxyz\E/ abc\$xyz /\Gabc/ abc \= Expect no match xyzabc /\Gabc./g abc1abc2xyzabc3 /abc./g abc1abc2xyzabc3 /a(?x: b c )d/ XabcdY \= Expect no match Xa b c d Y /((?x)x y z | a b c)/ XabcY AxyzB /(?i)AB(?-i)C/ XabCY \= Expect no match XabcY /((?i)AB(?-i)C|D)E/ abCE DE \= Expect no match abcE abCe dE De /(.*)\d+\1/ abc123abc abc123bc /(.*)\d+\1/s abc123abc abc123bc /((.*))\d+\1/ abc123abc abc123bc # This tests for an IPv6 address in the form where it can have up to # eight components, one and only one of which is empty. This must be # an internal component. /^(?!:) # colon disallowed at start (?: # start of item (?: [0-9a-f]{1,4} | # 1-4 hex digits or (?(1)0 | () ) ) # if null previously matched, fail; else null : # followed by colon ){1,7} # end item; 1-7 of them required [0-9a-f]{1,4} $ # final hex number at end of string (?(1)|.) # check that there was an empty component /ix a123::a123 a123:b342::abcd a123:b342::324e:abcd a123:ddde:b342::324e:abcd a123:ddde:b342::324e:dcba:abcd a123:ddde:9999:b342::324e:dcba:abcd \= Expect no match 1:2:3:4:5:6:7:8 a123:bce:ddde:9999:b342::324e:dcba:abcd a123::9999:b342::324e:dcba:abcd abcde:2:3:4:5:6:7:8 ::1 abcd:fee0:123:: :1 1: /[z\Qa-d]\E]/ z a - d ] \= Expect no match b /(a+)*b/ \= Expect no match aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /(?i)reg(?:ul(?:[a]|ae)r|ex)/ REGular regulaer Regex regulr /[--]+/ /(?<=Z)X./ \x84XAZXB /ab cd (?x) de fg/ ab cd defg /ab cd(?x) de fg/ ab cddefg \= Expect no match abcddefg /(?a|)*\d/ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4 \= Expect no match aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /(?:a|)*\d/ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4 \= Expect no match aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /\Z/g abc\n /^(?s)(?>.*)(?(a))b|(a)c/ ac /(?=(a))ab|(a)c/ ac /((?>(a))b|(a)c)/ ac /((?>(a))b|(a)c)++/ ac /(?:(?>(a))b|(a)c)++/ ac /(?=(?>(a))b|(a)c)(..)/ ac /(?>(?>(a))b|(a)c)/ ac /(?:(?>([ab])))+a=/aftertext =ba= /(?>([ab]))+a=/aftertext =ba= /((?>(a+)b)+(aabab))/ aaaabaaabaabab /(?>a+|ab)+?c/ \= Expect no match aabc /(?>a+|ab)+c/ \= Expect no match aabc /(?:a+|ab)+c/ aabc /(?(?=(a))a)/ a /(?(?=(a))a)(b)/ ab /^(?:a|ab)++c/ \= Expect no match aaaabc /^(?>a|ab)++c/ \= Expect no match aaaabc /^(?:a|ab)+c/ aaaabc /(?=abc){3}abc/aftertext abcabcabc \= Expect no match xyz /(?=abc)+abc/aftertext abcabcabc \= Expect no match xyz /(?=abc)++abc/aftertext abcabcabc \= Expect no match xyz /(?=abc){0}xyz/ xyz /(?=abc){1}xyz/ \= Expect no match xyz /(?=(a))?./ ab bc /(?=(a))??./ ab bc /^(?=(?1))?[az]([abc])d/ abd zcdxx /^(?!a){0}\w+/ aaaaa /(?<=(abc))?xyz/ abcxyz pqrxyz /^[\g]+/ ggg<<>> \= Expect no match \\ga /^[\ga]+/ gggagagaxyz /^[:a[:digit:]]+/ aaaa444:::Z /^[:a[:digit:]:b]+/ aaaa444:::bbbZ /[:a]xxx[b:]/ :xxx: /(?<=a{2})b/i xaabc \= Expect no match xabc /(?XNNNYZ > X NYQZ \= Expect no match >XYZ > X NY Z /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/ >XY\x0aZ\x0aA\x0bNN\x0c >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c /(foo)\Kbar/ foobar /(foo)(\Kbar|baz)/ foobar foobaz /(foo\Kbar)baz/ foobarbaz /abc\K|def\K/g,aftertext Xabcdefghi /ab\Kc|de\Kf/g,aftertext Xabcdefghi /(?=C)/g,aftertext ABCDECBA /^abc\K/aftertext abcdef \= Expect no match defabcxyz /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/ ababababbbabZXXXX /(?tom|bon)-\g{A}/ tom-tom bon-bon /(^(a|b\g{-1}))/ \= Expect no match bacxxx /(?|(abc)|(xyz))\1/ abcabc xyzxyz \= Expect no match abcxyz xyzabc /(?|(abc)|(xyz))(?1)/ abcabc xyzabc \= Expect no match xyzxyz /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/ XYabcdY /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/ XYabcdY /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/ XYabcdY /(?'abc'\w+):\k{2}/ a:aaxyz ab:ababxyz \= Expect no match a:axyz ab:abxyz /(?'abc'\w+):\g{abc}{2}/ a:aaxyz ab:ababxyz \= Expect no match a:axyz ab:abxyz /^(?a)? (?()b|c) (?('ab')d|e)/x abd ce /^(a.)\g-1Z/ aXaXZ /^(a.)\g{-1}Z/ aXaXZ /^(?(DEFINE) (? a) (? b) ) (?&A) (?&B) /x abcd /(?(?:(?:a(?&all))|(b))(c?))/ aabc /(a(b)|(c))(?1)/ abc cab /(?1)(a(b)|(c))/ abc cab /(?(?&NAME_PAT))\s+(?(?&ADDRESS_PAT)) (?(DEFINE) (?[a-z]+) (?\d+) )/x metcalfe 33 /(?(DEFINE)(?2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/ 1.2.3.4 131.111.10.206 10.0.0.0 \= Expect no match 10.6 455.3.4.5 /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/ 1.2.3.4 131.111.10.206 10.0.0.0 \= Expect no match 10.6 455.3.4.5 /^(\w++|\s++)*$/ now is the time for all good men to come to the aid of the party \= Expect no match this is not a line with only words and spaces! /(\d++)(\w)/ 12345a \= Expect no match 12345+ /a++b/ aaab /(a++b)/ aaab /(a++)b/ aaab /([^()]++|\([^()]*\))+/ ((abc(ade)ufh()()x /\(([^()]++|\([^()]+\))+\)/ (abc) (abc(def)xyz) \= Expect no match ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /^([^()]|\((?1)*\))*$/ abc a(b)c a(b(c))d \= Expect no match) a(b(c)d /^>abc>([^()]|\((?1)*\))*abc>123abc>1(2)3abc>(1(2)3)]*+) | (?2)) * >))/x <> hij> hij> def> \= Expect no match a)(?<=b(?&X))/ baz /^(?|(abc)|(def))\1/ abcabc defdef \= Expect no match abcdef defabc /^(?|(abc)|(def))(?1)/ abcabc defabc \= Expect no match defdef abcdef /(?:a(? (?')|(?")) |b(? (?')|(?")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames a\"aaaaa b\"aaaaa \= Expect no match b\"11111 /(?:(?1)|B)(A(*F)|C)/ ABCD CCD \= Expect no match CAD /^(?:(?1)|B)(A(*F)|C)/ CCD BCD \= Expect no match ABCD CAD BAD /(?:(?1)|B)(A(*ACCEPT)XX|C)D/ AAD ACD BAD BCD BAX \= Expect no match ACX ABC /(?(DEFINE)(A))B(?1)C/ BAC /(?(DEFINE)((A)\2))B(?1)C/ BAAC /(? \( ( [^()]++ | (?&pn) )* \) )/x (ab(cd)ef) /^(?=a(*SKIP)b|ac)/ \= Expect no match ac /^(?=a(*PRUNE)b)/ ab \= Expect no match ac /^(?=a(*ACCEPT)b)/ ac /(?>a\Kb)/ ab /((?>a\Kb))/ ab /(a\Kb)/ ab /^a\Kcz|ac/ ac /(?>a\Kbz|ab)/ ab /^(?&t)(?(DEFINE)(?a\Kb))$/ ab /^([^()]|\((?1)*\))*$/ a(b)c a(b(c)d)e /(?P(?P0)(?P>L1)|(?P>L2))/ 0 00 0000 /(?P(?P0)|(?P>L2)(?P>L1))/ 0 00 0000 # This one does fail, as expected, in Perl. It needs the complex item at the # end of the pattern. A single letter instead of (B|D) makes it not fail, which # I think is a Perl bug. /A(*COMMIT)(B|D)/ \= Expect no match ACABX # Check the use of names for failure /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark \= Expect no match AC CB /(*MARK:A)(*SKIP:B)(C|X)/mark C \= Expect no match D /^(A(*THEN:A)B|C(*THEN:B)D)/mark \= Expect no match CB /^(?:A(*THEN:A)B|C(*THEN:B)D)/mark \= Expect no match CB /^(?>A(*THEN:A)B|C(*THEN:B)D)/mark \= Expect no match CB # This should succeed, as the skip causes bump to offset 1 (the mark). Note # that we have to have something complicated such as (B|Z) at the end because, # for Perl, a simple character somehow causes an unwanted optimization to mess # with the handling of backtracking verbs. /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/x,mark AAAC # Test skipping over a non-matching mark. /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/x,mark AAAC # Check shorthand for MARK. /A(*:A)A+(*SKIP:A)(B|Z) | AC/x,mark AAAC /(*:A)A+(*SKIP:A)(B|Z)/mark \= Expect no match AAAC # This should succeed, as a non-existent skip name disables the skip. /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark AAAC /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/x,mark AAAC # COMMIT at the start of a pattern should act like an anchor. Again, however, # we need the complication for Perl. /(*COMMIT)(A|P)(B|P)(C|P)/ ABCDEFG \= Expect no match DEFGABC # COMMIT inside an atomic group can't stop backtracking over the group. /(\w+)(?>b(*COMMIT))\w{2}/ abbb /(\w+)b(*COMMIT)\w{2}/ \= Expect no match abbb # Check opening parens in comment when seeking forward reference. /(?&t)(?#()(?(DEFINE)(?a))/ bac # COMMIT should override THEN. /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/ \= Expect no match yes /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/ \= Expect no match yes /b?(*SKIP)c/ bc abc /(*SKIP)bc/ \= Expect no match a /(*SKIP)b/ \= Expect no match a /(?P(?P=abn)xxx|)+/ xxx /(?i:([^b]))(?1)/ aa aA \= Expect no match ab aB Ba ba /^(?&t)*+(?(DEFINE)(?a))\w$/ aaaaaaX \= Expect no match aaaaaa /^(?&t)*(?(DEFINE)(?a))\w$/ aaaaaaX aaaaaa /^(a)*+(\w)/ aaaaX YZ \= Expect no match aaaa /^(?:a)*+(\w)/ aaaaX YZ \= Expect no match aaaa /^(a)++(\w)/ aaaaX \= Expect no match aaaa YZ /^(?:a)++(\w)/ aaaaX \= Expect no match aaaa YZ /^(a)?+(\w)/ aaaaX YZ /^(?:a)?+(\w)/ aaaaX YZ /^(a){2,}+(\w)/ aaaaX \= Expect no match aaa YZ /^(?:a){2,}+(\w)/ aaaaX \= Expect no match aaa YZ /(a|)*(?1)b/ b ab aab /(a)++(?1)b/ \= Expect no match ab aab /(a)*+(?1)b/ \= Expect no match ab aab /(?1)(?:(b)){0}/ b /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x foo(bar(baz)+baz(bop)) /(A (A|B(*ACCEPT)|C) D)(E)/x AB /\A.*?(a|bc)/ ba /\A.*?(?:a|bc)++/ ba /\A.*?(a|bc)++/ ba /\A.*?(?:a|bc|d)/ ba /(?:(b))++/ beetle /(?(?=(a(*ACCEPT)z))a)/ a /^(a)(?1)+ab/ aaaab /^(a)(?1)++ab/ \= Expect no match aaaab /^(?=a(*:M))aZ/mark aZbc /^(?!(*:M)b)aZ/mark aZbc /(?(DEFINE)(a))?b(?1)/ backgammon /^\N+/ abc\ndef /^\N{1,}/ abc\ndef /(?(R)a+|(?R)b)/ aaaabcde /(?(R)a+|((?R))b)/ aaaabcde /((?(R)a+|(?1)b))/ aaaabcde /((?(R1)a+|(?1)b))/ aaaabcde /((?(R)a|(?1)))*/ aaa /((?(R)a|(?1)))+/ aaa /a(*:any name)/mark abc /(?>(?&t)c|(?&t))(?(DEFINE)(?a|b(*PRUNE)c))/ a ba bba # Checking revised (*THEN) handling. # Capture /^.*? (a(*THEN)b) c/x \= Expect no match aabc /^.*? (a(*THEN)b|(*F)) c/x aabc /^.*? ( (a(*THEN)b) | (*F) ) c/x aabc /^.*? ( (a(*THEN)b) ) c/x \= Expect no match aabc # Non-capture /^.*? (?:a(*THEN)b) c/x \= Expect no match aabc /^.*? (?:a(*THEN)b|(*F)) c/x aabc /^.*? (?: (?:a(*THEN)b) | (*F) ) c/x aabc /^.*? (?: (?:a(*THEN)b) ) c/x \= Expect no match aabc # Atomic /^.*? (?>a(*THEN)b) c/x \= Expect no match aabc /^.*? (?>a(*THEN)b|(*F)) c/x aabc /^.*? (?> (?>a(*THEN)b) | (*F) ) c/x aabc /^.*? (?> (?>a(*THEN)b) ) c/x \= Expect no match aabc # Possessive capture /^.*? (a(*THEN)b)++ c/x \= Expect no match aabc /^.*? (a(*THEN)b|(*F))++ c/x aabc /^.*? ( (a(*THEN)b)++ | (*F) )++ c/x aabc /^.*? ( (a(*THEN)b)++ )++ c/x \= Expect no match aabc # Possessive non-capture /^.*? (?:a(*THEN)b)++ c/x \= Expect no match aabc /^.*? (?:a(*THEN)b|(*F))++ c/x aabc /^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x aabc /^.*? (?: (?:a(*THEN)b)++ )++ c/x \= Expect no match aabc # Condition assertion /^(?(?=a(*THEN)b)ab|ac)/ ac # Condition /^.*?(?(?=a)a|b(*THEN)c)/ \= Expect no match ba /^.*?(?:(?(?=a)a|b(*THEN)c)|d)/ ba /^.*?(?(?=a)a(*THEN)b|c)/ \= Expect no match ac # Assertion /^.*(?=a(*THEN)b)/ aabc # -------------------------- /(?>a(*:m))/imsx,mark a /(?>(a)(*:m))/imsx,mark a /(?<=a(*ACCEPT)b)c/ xacd /(?<=(a(*ACCEPT)b))c/ xacd /(?<=(a(*COMMIT)b))c/ xabcd \= Expect no match xacd /(?a?)*)*c/ aac /(?>.*?a)(?<=ba)/ aba /(?:.*?a)(?<=ba)/ aba /(?>.*?a)b/s aab /(?>.*?a)b/ aab /(?>^a)b/s \= Expect no match aab /(?>.*?)(?<=(abcd)|(wxyz))/ alphabetabcd endingwxyz /(?>.*)(?<=(abcd)|(wxyz))/ alphabetabcd endingwxyz /(?>.*)foo/ \= Expect no match abcdfooxyz /(?>.*?)foo/ abcdfooxyz /(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/ ac /(?:(a(*SKIP)b)){0}(?:(?1)|ac)/ ac /(?<=(*SKIP)ac)a/ \= Expect no match aa /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark AAAC /a(*SKIP:m)x|ac(*:n)(*SKIP:n)d|ac/mark acacd /A(*SKIP:m)x|A(*SKIP:n)x|AB/mark AB /((*SKIP:r)d){0}a(*SKIP:m)x|ac(*:n)|ac/mark acacd # Tests that try to figure out how Perl works. My hypothesis is that the first # verb that is backtracked onto is the one that acts. This seems to be the case # almost all the time, but there is one exception that is perhaps a bug. # This matches "aaaac"; each PRUNE advances one character until the subject no # longer starts with 5 'a's. /aaaaa(*PRUNE)b|a+c/ aaaaaac # Putting SKIP in front of PRUNE makes no difference, as it is never # backtracked onto, whether or not it has a label. /aaaaa(*SKIP)(*PRUNE)b|a+c/ aaaaaac /aaaaa(*SKIP:N)(*PRUNE)b|a+c/ aaaaaac /aaaa(*:N)a(*SKIP:N)(*PRUNE)b|a+c/ aaaaaac # Putting THEN in front makes no difference. /aaaaa(*THEN)(*PRUNE)b|a+c/ aaaaaac # However, putting COMMIT in front of the prune changes it to "no match". I # think this is inconsistent and possibly a bug. For the moment, running this # test is moved out of the Perl-compatible file. /aaaaa(*COMMIT)(*PRUNE)b|a+c/ # OK, lets play the same game again using SKIP instead of PRUNE. # This matches "ac" because SKIP forces the next match to start on the # sixth "a". /aaaaa(*SKIP)b|a+c/ aaaaaac # Putting PRUNE in front makes no difference. /aaaaa(*PRUNE)(*SKIP)b|a+c/ aaaaaac # Putting THEN in front makes no difference. /aaaaa(*THEN)(*SKIP)b|a+c/ aaaaaac # In this case, neither does COMMIT. This still matches "ac". /aaaaa(*COMMIT)(*SKIP)b|a+c/ aaaaaac # This gives "no match", as expected. /aaaaa(*COMMIT)b|a+c/ \= Expect no match aaaaaac # ---- Tests using THEN ---- # This matches "aaaaaac", as expected. /aaaaa(*THEN)b|a+c/ aaaaaac # Putting SKIP in front makes no difference. /aaaaa(*SKIP)(*THEN)b|a+c/ aaaaaac # Putting PRUNE in front makes no difference. /aaaaa(*PRUNE)(*THEN)b|a+c/ aaaaaac # Putting COMMIT in front makes no difference. /aaaaa(*COMMIT)(*THEN)b|a+c/ aaaaaac # End of "priority" tests /aaaaa(*:m)(*PRUNE:m)(*SKIP:m)m|a+/ aaaaaa /aaaaa(*:m)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/ aaaaaa /aaaaa(*:n)(*PRUNE:m)(*SKIP:m)m|a+/ aaaaaa /aaaaa(*:n)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/ aaaaaa /a(*MARK:A)aa(*PRUNE:A)a(*SKIP:A)b|a+c/ aaaac /a(*MARK:A)aa(*MARK:A)a(*SKIP:A)b|a+c/ aaaac /aaa(*PRUNE:A)a(*SKIP:A)b|a+c/ aaaac /aaa(*MARK:A)a(*SKIP:A)b|a+c/ aaaac /a(*:m)a(*COMMIT)(*SKIP:m)b|a+c/mark aaaaaac /.?(a|b(*THEN)c)/ ba /(a(*COMMIT)b)c|abd/ abc \= Expect no match abd /(?=a(*COMMIT)b)abc|abd/ abc abd /(?>a(*COMMIT)b)c|abd/ abc abd /a(?=b(*COMMIT)c)[^d]|abd/ abc \= Expect no match abd /a(?=bc).|abd/ abd abc /a(?>b(*COMMIT)c)d|abd/ \= Expect no match abceabd /a(?>bc)d|abd/ abceabd /(?>a(*COMMIT)b)c|abd/ abd /(?>a(*COMMIT)c)d|abd/ \= Expect no match abd /((?=a(*COMMIT)b)ab|ac){0}(?:(?1)|a(c))/ ac # These tests were formerly in test 2, but changes in PCRE and Perl have # made them compatible. /^(a)?(?(1)a|b)+$/ \= Expect no match a /A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark \= Expect no match AAAC /^((abc|abcx)(*THEN)y|abcd)/ abcd \= Expect no match abcxy /^((yes|no)(*THEN)(*F))?/ \= Expect no match yes /(A (.*) C? (*THEN) | A D) (*FAIL)/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) C? (*THEN) | A D) z/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) C? (*THEN) | A D) \s* (*FAIL)/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) C? (*THEN) | A D) \s* z/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) (?:C|) (*THEN) | A D) (*FAIL)/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) (?:C|) (*THEN) | A D) z/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) C{0,6} (*THEN) | A D) (*FAIL)/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) C{0,6} (*THEN) | A D) z/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) (CE){0,6} (*THEN) | A D) (*FAIL)/x \= Expect no match AbcdCEBefgBhiBqz /(A (.*) (CE){0,6} (*THEN) | A D) z/x \= Expect no match AbcdCEBefgBhiBqz /(A (.*) (CE*){0,6} (*THEN) | A D) (*FAIL)/x \= Expect no match AbcdCBefgBhiBqz /(A (.*) (CE*){0,6} (*THEN) | A D) z/x \= Expect no match AbcdCBefgBhiBqz /(?=a(*COMMIT)b|ac)ac|ac/ \= Expect no match ac /(?=a(*COMMIT)b|(ac)) ac | (a)c/x \= Expect no match ac # ---- /(?(?!b(*THEN)a)bn|bnn)/ bnn /(?!b(*SKIP)a)bn|bnn/ bnn /(?(?!b(*SKIP)a)bn|bnn)/ bnn /(?!b(*PRUNE)a)bn|bnn/ bnn /(?(?!b(*PRUNE)a)bn|bnn)/ bnn /(?!b(*COMMIT)a)bn|bnn/ bnn /(?(?!b(*COMMIT)a)bn|bnn)/ bnn /(?=b(*SKIP)a)bn|bnn/ \= Expect no match bnn /(?=b(*THEN)a)bn|bnn/ bnn /^(?!a(*SKIP)b)/ ac /^(?!a(*SKIP)b)../ acd /(?!a(*SKIP)b)../ acd /^(?(?!a(*SKIP)b))/ ac /^(?!a(*PRUNE)b)../ acd /(?!a(*PRUNE)b)../ acd /(?!a(*COMMIT)b)ac|cd/ ac /\A.*?(?:a|bc)/ ba /^(A(*THEN)B|C(*THEN)D)/ CD /(*:m(m)(?&y)(?(DEFINE)(?b))/mark abc /(*PRUNE:m(m)(?&y)(?(DEFINE)(?b))/mark abc /(*SKIP:m(m)(?&y)(?(DEFINE)(?b))/mark abc /(*THEN:m(m)(?&y)(?(DEFINE)(?b))/mark abc /^\d*\w{4}/ 1234 \= Expect no match 123 /^[^b]*\w{4}/ aaaa \= Expect no match aaa /^[^b]*\w{4}/i aaaa \= Expect no match aaa /^a*\w{4}/ aaaa \= Expect no match aaa /^a*\w{4}/i aaaa \= Expect no match aaa /(?:(?foo)|(?bar))\k/dupnames foofoo barbar /(?A)(?:(?foo)|(?bar))\k/dupnames AfooA AbarA \= Expect no match Afoofoo Abarbar /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/ 1 IN SOA non-sp1 non-sp2( /^ (?:(?A)|(?'B'B)(?A)) (?('A')x) (?()y)$/x,dupnames Ax BAxy /^A\xZ/ A\0Z /^A\o{123}B/ A\123B / ^ a + + b $ /x aaaab / ^ a + #comment + b $ /x aaaab / ^ a + #comment #comment + b $ /x aaaab / ^ (?> a + ) b $ /x aaaab / ^ ( a + ) + + \w $ /x aaaab /(?:a\Kb)*+/aftertext ababc /(?>a\Kb)*/aftertext ababc /(?:a\Kb)*/aftertext ababc /(a\Kb)*+/aftertext ababc /(a\Kb)*/aftertext ababc /(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/ \= Expect no match acb /\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++/ NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED /\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++/ NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED /\A(?:[^\"]++|\"(?:[^\"]++|\"\")++\")++/ NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED /\A([^\"1]++|[\"2]([^\"3]*+|[\"4][\"5])*+[\"6])++/ NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED /^\w+(?>\s*)(?<=\w)/ test test /(?Pa)(?Pb)/g,dupnames abbaba /(?Pa)(?Pb)(?P=same)/g,dupnames abbaba /(?P=same)?(?Pa)(?Pb)/g,dupnames abbaba /(?:(?P=same)?(?:(?P=same)(?Pa)(?P=same)|(?P=same)?(?Pb)(?P=same)){2}(?P=same)(?Pc)(?P=same)){2}(?Pz)?/g,dupnames \= Expect no match bbbaaaccccaaabbbcc /(?Pa)?(?Pb)?(?()c|d)*l/ acl bdl adl bcl /\sabc/ \x{0b}abc /[\Qa]\E]+/ aa]] /[\Q]a\E]+/ aa]] /A((((((((a))))))))\8B/ AaaB /A(((((((((a)))))))))\9B/ AaaB /A[\8\9]B/ A8B A9B /(|ab)*?d/ abd xyd /(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/ 1234abcd /(\2|a)(\1)/ aaa /(\2)(\1)/ /Z*(|d*){216}/ /(?1)(?#?'){8}(a)/ baaaaaaaaac /((((((((((((x))))))))))))\12/ xx /A[\8]B[\9]C/ A8B9C /(?1)()((((((\1++))\x85)+)|))/ \x85\x85 /(?|(\k'Pm')|(?'Pm'))/ abcd /(?|(aaa)|(b))\g{1}/ aaaaaa bb /(?|(aaa)|(b))(?1)/ aaaaaa baaa \= Expect no match bb /(?|(aaa)|(b))/ xaaa xbc /(?|(?'a'aaa)|(?'a'b))\k'a'/ aaaaaa bb /(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/dupnames aaaccccaaa bccccb # /x does not apply to MARK labels /x (*MARK:ab cd # comment ef) x/x,mark axxz /(?<=a(B){0}c)X/ acX /(?b)(?(DEFINE)(a+))(?&DEFINE)/ bbbb \= Expect no match baaab /(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])/ \ Fred:099 /(?=.*X)X$/ \ X /(?s)(?=.*?)b/ aabc /(Z)(a)\2{1,2}?(?-i)\1X/i ZaAAZX /(?'c')XX(?'YYYYYYYYYYYYYYYYYYYYYYYCl')/ /[s[:digit:]\E-H]+/ s09-H /[s[:digit:]\Q\E-H]+/ s09-H /a+(?:|b)a/ aaaa /X?(R||){3335}/ /(?1)(A(*COMMIT)|B)D/ ABD XABD BAD ABXABD \= Expect no match ABX /(?(DEFINE)(? 1? (?=(?2)?) 1 2 (?('cond')|3))) \A () (?&m) \Z/x 123 /^(?: (?: A| (1? (?=(?2)?) (1) 2 (?('cond')|3)) ) (Z) )+$/x AZ123Z \= Expect no match AZ12Z /^ (?(DEFINE) ( (?!(a)\2b)..) ) ()(?1) /x acb \= Expect no match aab /(?>ab|abab){1,5}?M/ abababababababababababM /(?>ab|abab){2}?M/ abababM /((?(?=(a))a)+k)/ bbak /((?(?=(a))a|)+k)/ bbak /(?(?!(b))a|b)+k/ ababbalbbadabak /(?!(b))c|b/ Ab Ac /(?=(b))b|c/ Ab Ac /^(.|(.)(?1)\2)$/ a aba abcba ababa abcdcba /^((.)(?1)\2|.?)$/ a aba abba abcba ababa abccba abcdcba abcddcba /^(.)(\1|a(?2))/ bab /^(.|(.)(?1)?\2)$/ abcba /^(?(?=(a))abc|def)/ abc /^(?(?!(a))def|abc)/ abc /^(?(?=(a)(*ACCEPT))abc|def)/ abc /^(?(?!(a)(*ACCEPT))def|abc)/ abc /^(?1)\d{3}(a)/ a123a # This pattern uses a lot of named subpatterns in order to match email # addresses in various formats. It's a heavy test for named subpatterns. In the # group, slash is coded as \x{2f} so that this pattern can also be # processed by perltest.sh, which does not cater for an escaped delimiter # within the pattern. $ within the pattern must also be escaped. All $ and @ # characters in subject strings are escaped so that Perl doesn't interpret them # as variable insertions and " characters must also be escaped for Perl. # This set of subpatterns is more or less a direct transliteration of the BNF # definitions in RFC2822, without any of the obsolete features. The addition of # a possessive + to the definition of reduced the match limit in PCRE2 # from over 5 million to just under 400, and eliminated a very noticeable delay # when this file was passed to perltest.sh. /(?ix)(?(DEFINE) (? (?&local_part) \@ (?&domain) ) (? (?&CFWS)?+ < (?&addr_spec) > (?&CFWS)?+ ) (? [a-z\d!#\$%&'*+-\x{2f}=?^_`{|}~] ) (? (?&CFWS)?+ (?&atext)+ (?&CFWS)?+ ) (? (?&ctext) | (?"ed_pair) | (?&comment) ) (? [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ ()\\] ) (? \( (?: (?&FWS)?+ (?&ccontent) )*+ (?&FWS)?+ \) ) (? (?: (?&FWS)?+ (?&comment) )* (?# NOT possessive) (?: (?&FWS)?+ (?&comment) | (?&FWS) ) ) (? (?&dtext) | (?"ed_pair) ) (? (?&phrase) ) (? (?&dot_atom) | (?&domain_literal) ) (? (?&CFWS)?+ \[ (?: (?&FWS)?+ (?&dcontent) )* (?&FWS)?+ \] (?&CFWS)?+ ) (? (?&CFWS)?+ (?&dot_atom_text) (?&CFWS)?+ ) (? (?&atext)++ (?: \. (?&atext)++)*+ ) (? [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ \[\]\\] ) (? (?: [\t\ ]*+ \n)?+ [\t\ ]++ ) (? (?&dot_atom) | (?"ed_string) ) (? (?&name_addr) | (?&addr_spec) ) (? (?&display_name)? (?&angle_addr) ) (? (?&word)++ ) (? (?&qtext) | (?"ed_pair) ) (? " (?&text) ) (? (?&CFWS)?+ " (?: (?&FWS)?+ (?&qcontent))* (?&FWS)?+ " (?&CFWS)?+ ) (? [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ "\\] ) (? [^\r\n] ) (? (?&atom) | (?"ed_string) ) ) # End DEFINE ^(?&mailbox)$/ Alan Other user\@dom.ain user\@[] user\@[domain literal] user\@[domain literal with \"[square brackets\"] inside] \"A. Other\" (a comment) A. Other (a comment) \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay \= Expect no match A missing angle (?&simple_assertion) | (?&lookaround) ) (? \( \? > (?®ex) \) ) (? \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) ) (? (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?"ed_string) | (?"ed_string_empty) | (?&special_escape) | (?&verb) )* ) (? \(\?C (?: \d+ | (?: (?["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) ) (? \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?®ex) \) ) (? \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] ) (? (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] ) (? (?: \[ : (?: alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print| punct|space|upper|word|xdigit ) : \] | (?"ed_string) | (?"ed_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) ) (? \(\?\# [^)]* \) | (?"ed_string_empty) | \\E ) (? (?: \( [+-]? \d+ \) | \( < (?&groupname) > \) | \( ' (?&groupname) ' \) | \( R \d* \) | \( R & (?&groupname) \) | \( (?&groupname) \) | \( DEFINE \) | \( VERSION >?=\d+(?:\.\d\d?)? \) | (?&callout)?+ (?&comment)* (?&lookaround) ) ) (? \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) ) (? (? [-\x{2f}!"'`=_:;,%&@~]) (?®ex) \k'delimiter' .* ) (? \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} | x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} | [aefnrt] | c[[:print:]] | [^[:alnum:]] ) ) (? (?&capturing_group) | (?&non_capturing_group) | (?&resetting_group) | (?&atomic_group) | (?&conditional_group) ) (? [a-zA-Z_]\w* ) (? (?! (?&range_qualifier) ) [^[()|*+?.\$\\] ) (? \(\? (?: = | ! | <= | \(\? [iJmnsUx-]* : (?®ex) \) ) (? \(\? [iJmnsUx-]* \) ) (? (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?"ed_string) ) (?&comment)? (?&qualifier)? ) (? (?: [?*+] | (?&range_qualifier) ) [+?]? ) (? (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) ) (? \\Q\\E ) (? \{ (?: \d+ (?: , \d* )? | , \d+ ) \} ) (? (?&start_item)* (?&branch) (?: \| (?&branch) )* ) (? \( \? \| (?®ex) \) ) (? \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z ) (? \\K ) (? \( \* (?: 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 ) \) ) (? (?: \(\?R\) | \(\?[+-]?\d+\) | \(\? (?: & | P> ) (?&groupname) \) | \\g < (?&groupname) > | \\g ' (?&groupname) ' | \\g < [+-]? \d+ > | \\g ' [+-]? \d+ ) ) (? \(\* (?: ACCEPT | FAIL | F | COMMIT | (?:MARK)?:(?&verbname) | (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) ) (? [^)]+ ) ) # End DEFINE # Kick it all off... ^(?&delimited_regex)$/subject_literal,jitstack=256 /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/ /(cat(a(ract|tonic)|erpillar)) \1()2(3)/ /^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]/ /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/ /]{0,})>]{0,})>([\d]{0,}\.)(.*)((
([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/is /^(?(DEFINE) (?
a) (? b) ) (?&A) (?&B) / /(?(DEFINE)(?2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/ /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/ /^(\w++|\s++)*$/ /a+b?(*THEN)c+(*FAIL)/ /(A (A|B(*ACCEPT)|C) D)(E)/x /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B /(?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 /(?sx)(?(DEFINE)(? (?&simple_assertion) | (?&lookaround) )(? \( \? > (?®ex) \) )(? \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) )(? (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?"ed_string) | (?"ed_string_empty) | (?&special_escape) | (?&verb) )* )(? \(\?C (?: \d+ | (?: (?["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) )(? \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?®ex) \) )(? \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )(? (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )(? (?: \[ : (?: alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print| punct|space|upper|word|xdigit ) : \] | (?"ed_string) | (?"ed_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) )(? \(\?\# [^)]* \) | (?"ed_string_empty) | \\E )(? (?: \( [+-]? \d+ \) | \( < (?&groupname) > \) | \( ' (?&groupname) ' \) | \( R \d* \) | \( R & (?&groupname) \) | \( (?&groupname) \) | \( DEFINE \) | \( VERSION >?=\d+(?:\.\d\d?)? \) | (?&callout)?+ (?&comment)* (?&lookaround) ) )(? \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )(? (? [-\x{2f}!"'`=_:;,%&@~]) (?®ex) \k'delimiter' .* )(? \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} | x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} | [aefnrt] | c[[:print:]] | [^[:alnum:]] ) )(? (?&capturing_group) | (?&non_capturing_group) | (?&resetting_group) | (?&atomic_group) | (?&conditional_group) )(? [a-zA-Z_]\w* )(? (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )(? \(\? (?: = | ! | <= | \(\? [iJmnsUx-]* : (?®ex) \) )(? \(\? [iJmnsUx-]* \) )(? (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?"ed_string) ) (?&comment)? (?&qualifier)? )(? (?: [?*+] | (?&range_qualifier) ) [+?]? )(? (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) ) (? \\Q\\E ) (? \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )(? (?&start_item)* (?&branch) (?: \| (?&branch) )* )(? \( \? \| (?®ex) \) )(? \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )(? \\K )(? \( \* (?: 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 ) \) )(? (?: \(\?R\) | \(\?[+-]?\d+\) | \(\? (?: & | P> ) (?&groupname) \) | \\g < (?&groupname) > | \\g ' (?&groupname) ' | \\g < [+-]? \d+ > | \\g ' [+-]? \d+ ) )(? \(\* (?: ACCEPT | FAIL | F | COMMIT | (?:MARK)?:(?&verbname) | (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )(? [^)]+ ))^(?&delimited_regex)$/ \= Expect no match /((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/ /(?:(?(2y)a|b)(X))+/ /a(*MARK)b/ /a(*CR)b/ /(?P(?P=abn)(?/xx < > /<(?:[a b])>/xx < > /<(?xxx:[a b])>/ < > /<(?-x:[a b])>/xx < > /[[:digit:]-]+/ 12-24 /((?<=((*ACCEPT)) )\1?\b) / \= Expect no match ((?<=((*ACCEPT)) )\\1?\\b)\x20 /((?<=((*ACCEPT))X)\1?Y)\1/ XYYZ /((?<=((*ACCEPT))X)\1?Y(*ACCEPT))\1/ XYYZ /(?(DEFINE)(?a?)X)^(?&optional_a)a$/ aa a /^(a?)b(?1)a/ abaa aba baa ba /^(a?)+b(?1)a/ abaa aba baa ba /^(a?)++b(?1)a/ abaa aba baa ba /^(a?)+b/ b ab aaab /(?=a+)a(a+)++b/ aab /(?<=\G.)/g,aftertext abc /(?<=(?=.)?)/ /(?<=(?=.)?+)/ /(?<=(?=.)*)/ /(?<=(?=.){4,5})/ /(?<=(?=.){4,5}x)/ /a(?=.(*:X))(*SKIP:X)(*F)|(.)/ abc /a(?>(*:X))(*SKIP:X)(*F)|(.)/ abc /a(?:(*:X))(*SKIP:X)(*F)|(.)/ abc #pattern no_start_optimize /(?>a(*:1))(?>b(*:1))(*SKIP:1)x|.*/ abc /(?>a(*:1))(?>b)(*SKIP:1)x|.*/ abc #subject mark /a(*ACCEPT:X)b/ abc /(?=a(*ACCEPT:QQ)bc)axyz/ axyz /(?(DEFINE)(a(*ACCEPT:X)))(?1)b/ abc /a(*F:X)b/ abc /(?(DEFINE)(a(*F:X)))(?1)b/ abc /a(*COMMIT:X)b/ abc /(?(DEFINE)(a(*COMMIT:X)))(?1)b/ abc /a+(*:Z)b(*COMMIT:X)(*SKIP:Z)c|.*/ aaaabd /a+(*:Z)b(*COMMIT:X)(*SKIP:X)c|.*/ aaaabd /a(*COMMIT:X)b/ axabc #pattern -no_start_optimize #subject -mark /(.COMMIT)(*COMMIT::::::::::interal error:::)/ /(*COMMIT:)/ /(*COMMIT:]w)/ /(?i)A(?^)B(?^x:C D)(?^i)e f/ aBCDE F \= Expect no match aBCDEF AbCDe f /(*pla:foo).{6}/ abcfoobarxyz \= Expect no match abcfooba /(*positive_lookahead:foo).{6}/ abcfoobarxyz /(?(*pla:foo).{6}|a..)/ foobarbaz abcfoobar /(?(*positive_lookahead:foo).{6}|a..)/ foobarbaz abcfoobar /(*plb:foo)bar/ abcfoobar \= Expect no match abcbarfoo /(*positive_lookbehind:foo)bar/ abcfoobar \= Expect no match abcbarfoo /(?(*plb:foo)bar|baz)/ abcfoobar bazfoobar abcbazfoobar foobazfoobar /(?(*positive_lookbehind:foo)bar|baz)/ abcfoobar bazfoobar abcbazfoobar foobazfoobar /(*nlb:foo)bar/ abcbarfoo \= Expect no match abcfoobar /(*negative_lookbehind:foo)bar/ abcbarfoo \= Expect no match abcfoobar /(?(*nlb:foo)bar|baz)/ abcfoobaz abcbarbaz \= Expect no match abcfoobar /(?(*negative_lookbehind:foo)bar|baz)/ abcfoobaz abcbarbaz \= Expect no match abcfoobar /(*atomic:a+)\w/ aaab \= Expect no match aaaa / (? \w+ )* \. /xi pokus. /(?(DEFINE) (? \w+ ) ) (?&word)* \./xi pokus. /(?(DEFINE) (? \w+ ) ) ( (?&word)* ) \./xi pokus. /(?&word)* (?(DEFINE) (? \w+ ) ) \./xi pokus. /(?&word)* \. (? \w+ )/xi pokus.hokus /a(?(?=(*:2)b).)/mark abc acb /a(?(?!(*:2)b).)/mark acb abc /(?:a|ab){1}+c/ \= Expect no match abc /(a|ab){1}+c/ abc /(a+){1}+a/ \= Expect no match aaaa /(?(DEFINE)(a|ab))(?1){1}+c/ abc /(?:a|(?=b)|.)*\z/ abc /(?:a|(?=b)|.)*/ abc /(?<=a(*SKIP)x)|c/ abcd /(?<=a(*SKIP)x)|d/ abcd /(?<=(?=.(?<=x)))/aftertext abx /(?<=(?=(?<=a)))b/ ab /^(?a)(?()b)((?<=b).*)$/ abc /^(a\1?){4}$/ aaaa aaaaaa /^((\1+)|\d)+133X$/ 111133X /^(?>.*?([A-Z])(?!.*\1)){26}/i The quick brown fox jumps over the lazy dog. Jackdaws love my big sphinx of quartz. Pack my box with five dozen liquor jugs. \= Expect no match The quick brown fox jumps over the lazy cat. Hackdaws love my big sphinx of quartz. Pack my fox with five dozen liquor jugs. /(?<=X(?(DEFINE)(A)))X(*F)/ \= Expect no match AXYZ /(?<=X(?(DEFINE)(A)))./ AXYZ /(?<=X(?(DEFINE)(.*))Y)./ AXYZ /(?<=X(?(DEFINE)(Y))(?1))./ AXYZ /(?(DEFINE)(?bar))(?\x{8c}748364< /a{65536/ >a{65536< /a\K.(?0)*/ abac /(a\K.(?1)*)/ abac # -------------------------------------------------------------------------- # Perl-compatible tests of variable-length lookbehinds. /(?<=ab?c).../g abcdefgacxyz /(?<=PQR|ab?c).../g abcdefgacxyzPQR123 /(?<=ab?c|PQR).../g abcdefgacxyzPQR123 /(?<=PQ|ab?c).../g abcdefgacxyzPQR123 /(?<=ab?c|PQ).../g abcdefgacxyzPQR123 /(?<=a(b?c|d?e?e)f)X./g acfX1zzzaefX2zzzadeefX3zzzX4zzz /(?)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)$/ # This is not very readable, and also does not handle all features. I have done # some work on it. /^ (? # A regular expression is zero or more of these items. (?: # An item is one of these: (?: [^?+*{}()\[\]\\|]++| # Non-meta characters or unquoted . \\.| # Quoted . \[ # Class, which is [ (?: # Followed by \^?\\.| # Optional ^ and any escaped character \^[^\\]| # OR ^ and not escaped character [^\\^] # OR neither ^ nor \ ) # Followed by (?:[^\]\\]+|\\.)*+ # Zero or more (not ] or \) OR escaped dot \]| # Class ends with ] \( # Parenthesized group (?: # Start with optional \?[:=!]| # ? followed by : = ! \?<[=!]| # OR ?< followed by = or ! \?> # OR ?> )? (?&re)?? # Then a nested \)| # End parenthesized group \(\? # Other parenthesized items (?: # (? followed by R| # R [+-]?\d++ # Or optional +- and digits ) \)| # End parens \(\* # Verbs (?: COMMIT| FAIL| MARK:[^)]*| (?:PRUNE|SKIP|THEN)(?::[^\)]*+)? ) \) ) # End list of items # Followed by an optional quantifier (?: (?: [?+*] # ?+* | # OR \{\d+ # { digits (?:,\d*)? # optionally followed by ,digits \} # then closing } | # OR \{,\d+} # {,digits} ) [?+]? # optional ungreedy or possessive )? | # OR an "item" is a branch ending \| )* # Zero or more top-level items. ) # End regex group. $/x [abcdef] [abc\\]def] a.b|abcd ab()d ab{1,3}d ab{,3}d ab(*FAIL)d(*COMMIT)(*SKIP)(*THEN:abc) ab(*MARK:xyz) (?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\\s]) abcd\\t\\n\\r\\f\\a\\e\\071\\x3b\\^\\\\\\?caxyz a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz \\G(?:(?=(\\1.|)(.))){1,13}?(?!.*\\2.*\\2)\\1\\K\\2 \= Expect no match ab)d ab(d {4,5} a[]b (a)(?(1)a|b|c) /^..A(*SKIP)B|C/ 12ADC /(?