2014-07-24 18:32:38 +02:00
# 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
2019-08-01 18:42:36 +02:00
# 32-bit PCRE libraries, and also using the perltest.sh script.
2014-07-24 18:32:38 +02:00
#forbid_utf
2015-09-08 19:01:17 +02:00
#newline_default lf any anycrlf
2014-07-24 18:32:38 +02:00
#perltest
/the quick brown fox/
the quick brown fox
What do you know about the quick brown fox?
2015-09-16 18:49:48 +02:00
\= Expect no match
The quick brown FOX
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abxyzpqrrabbxyyyypqAzz
abxyzpqrrrrabbxyyyypqAzz
abxyzpqrrrabxyyyypqAzz
aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
aaaabcxyzzzzpqrrrabbbxyyypqAzz
aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
/^(abc){1,2}zz/
abczz
abcabczz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
zz
abcabcabczz
>>abczz
/^(b+?|a){1,2}?c/
bc
bbc
bbbc
bac
bbac
aac
abbbbbbbbbbbc
bbbbbbbbbbbac
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaac
abbbbbbbbbbbac
/^(b+|a){1,2}c/
bc
bbc
bbbc
bac
bbac
aac
abbbbbbbbbbbc
bbbbbbbbbbbac
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaac
abbbbbbbbbbbac
/^(ba|b*){1,2}?bc/
babc
bbabc
bababc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bababbc
babababc
/^\ca\cA\c[;\c:/
\x01\x01\e;z
/^[ab\]cde]/
athing
bthing
]thing
cthing
dthing
ething
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
fthing
[thing
\\thing
/^[]cde]/
]thing
cthing
dthing
ething
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
athing
fthing
/^[^ab\]cde]/
fthing
[thing
\\thing
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
athing
bthing
]thing
cthing
dthing
ething
/^[^]cde]/
athing
fthing
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
]thing
cthing
dthing
ething
/^\<5C> /
<20>
/^<5E> /
<20>
/^[0-9]+$/
0
1
2
3
4
5
6
7
8
9
10
100
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/^.*nter/
enter
inter
uponter
/^xxx[0-9]+$/
xxx0
xxx1234
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xxx
/^.+[0-9][0-9][0-9]$/
x123
2015-09-16 18:49:48 +02:00
x1234
2014-07-24 18:32:38 +02:00
xx123
123456
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123
/^.+?[0-9][0-9][0-9]$/
x123
2015-09-16 18:49:48 +02:00
x1234
2014-07-24 18:32:38 +02:00
xx123
123456
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123
/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
abc!pqr=apquxz.ixr.zzz.ac.uk
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
!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
2015-09-16 18:49:48 +02:00
\= Expect no match
Fail without a colon
2014-07-24 18:32:38 +02:00
/([\da-f:]+)$/i
0abc
abc
fed
E
::
5f03:12C0::932e
fed def
Any old stuff
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
0zzz
gzzz
fed\x20
Any old rubbish
/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
.1.2.3
A.12.123.0
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
.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 (
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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-.
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
-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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
*.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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
\"1234\" : things
/^$/
\
2015-09-16 18:49:48 +02:00
\= Expect no match
A non-empty line
2014-07-24 18:32:38 +02:00
/ ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
ab c
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
ab cde
/(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
ab c
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
ab cde
/^ a\ b[c ]d $/x
a bcd
a b d
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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__
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1234567
/^[aeiou\d]{4,5}$/
uoie
1234
12345
aaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123456
/^[aeiou\d]{4,5}?/
uoie
1234
12345
aaaaa
123456
/\A(abc|def)=(\1){2,3}\Z/
abc=abcabc
def=defdefdef
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/(?=^)abc/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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>
<user\@dom.ain>
user\@dom.ain
\"A. Other\" <user.1234\@dom.ain> (a comment)
A. Other <user.1234\@dom.ain> (a comment)
\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
A missing angle <user\@some.where
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
The quick brown fox
/[\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 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
# 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>
<user\@dom.ain>
user\@dom.ain
\"A. Other\" <user.1234\@dom.ain> (a comment)
A. Other <user.1234\@dom.ain> (a comment)
\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
A missing angle <user\@some.where
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
The quick brown fox
/abc\0def\00pqr\000xyz\0000AB/
abc\0def\00pqr\000xyz\0000AB
abc456 abc\0def\00pqr\000xyz\0000ABCDE
/abc\x0def\x00pqr\x000xyz\x0000AB/
abc\x0def\x00pqr\x000xyz\x0000AB
abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
/^[\000-\037]/
\0A
\01B
\037C
/\0*/
\0\0\0\0
/A\x0{2,3}Z/
The A\x0\x0Z
An A\0\x0\0Z
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
A\0Z
A\0\x0\0\x0Z
/^(cow|)\1(bell)/
cowcowbell
bell
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
cowbell
/^\s/
\040abc
\x0cabc
\nabc
\rabc
\tabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/^a b
c/x
abc
/^(a|)\1*b/
ab
aaaab
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
acb
/^(a|)\1+b/
aab
aaaab
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab
/^(a|)\1?b/
ab
aab
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
acb
/^(a|)\1{2}b/
aaab
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab
aab
aaaab
/^(a|)\1{2,3}b/
aaab
aaaab
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab
aab
aaaaab
/ab{1,3}bc/
abbbbc
abbbc
abbc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
abbbbbc
/([^.]*)\.([^:]*):[T ]+(.*)/
track1.title:TBlah blah blah
/([^.]*)\.([^:]*):[T ]+(.*)/i
track1.title:TBlah blah blah
/([^.]*)\.([^:]*):[t ]+(.*)/i
track1.title:TBlah blah blah
/^[W-c]+$/
WXY_^abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
wxy
/^[W-c]+$/i
WXY_^abc
wxy_^ABC
/^[\x3f-\x5F]+$/i
WXY_^abc
wxy_^ABC
/^abc$/m
abc
qqq\nabc
abc\nzzz
qqq\nabc\nzzz
/^abc$/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
qqq\nabc
abc\nzzz
qqq\nabc\nzzz
/\Aabc\Z/m
abc
abc\n
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
qqq\nabc
abc\nzzz
qqq\nabc\nzzz
/\A(.)*\Z/s
abc\ndef
/\A(.)*\Z/m
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\ndef
/(?:b)|(?::+)/
b::c
c::b
/[-az]+/
az-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b
/[az-]+/
za-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b
/[a\-z]+/
a-z
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b
/[a-z]+/
abcdxyz
/[\d-]+/
12-34
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/\x5c/
\\
/\x20Z/
the Zoo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Zulu
/(abc)\1/i
abcabc
ABCabc
abcABC
/abc$/
abc
abc\n
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\ndef
/(abc)\123/
abc\x53
/(abc)\223/
abc\x93
/(abc)\323/
abc\xd3
/(abc)\100/
abc\x40
abc\100
/(abc)\1000/
abc\x400
abc\x40\x30
abc\1000
abc\100\x30
abc\100\060
abc\100\60
/^(A)(B)(C)(D)(E)(F)(G)(H)(I)\8\9$/
ABCDEFGHIHI
/^[A\8B\9C]+$/
A8B9C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
A8B9C\x00
/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
abcdefghijkllS
/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
abcdefghijk\12S
/a{0}bc/
bc
/(a|(bc)){0,0}?xyz/
xyz
/abc[\10]de/
abc\010de
/abc[\1]de/
abc\1de
/(abc)[\1]de/
abc\1de
/(?s)a.b/
a\nb
/^([^a])([^\b])([^c]*)([^d]{3,4})/
baNOTccccd
baNOTcccd
baNOTccd
bacccd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
anything
b\bc
baccd
/[^a]/
Abc
/[^a]/i
Abc
/[^a]+/
AAAaAbc
/[^a]+/i
AAAaAbc
/[^a]+/
bbb\nccc
/[^k]$/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abk
/[^k]{2,3}$/
abc
kbc
kabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abk
akb
akk
/^\d{8,}\@.+[^k]$/
12345678\@a.b.c.d
123456789\@x.y.z
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
12345678\@x.y.uk
1234567\@a.b.c.d
/(a)\1{8,}/
aaaaaaaaa
aaaaaaaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaaa
/[^a]/
aaaabcd
aaAabcd
/[^a]/i
aaaabcd
aaAabcd
/[^az]/
aaaabcd
aaAabcd
/[^az]/i
aaaabcd
aaAabcd
/\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/
\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
/P[^*]TAIRE[^*]{1,6}?LL/
xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
/P[^*]TAIRE[^*]{1,}?LL/
xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
/(\.\d\d[1-9]?)\d+/
1.230003938
1.875000282
1.235
/(\.\d\d((?=0)|\d(?=\d)))/
1.230003938
1.875000282
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1.235
/a(?)b/
ab
/\b(foo)\s+(\w+)/i
Food is on the foo table
/foo(.*)bar/
The food is under the bar in the barn.
/foo(.*?)bar/
The food is under the bar in the barn.
/(.*)(\d*)/
I have 2 numbers: 53147
/(.*)(\d+)/
I have 2 numbers: 53147
/(.*?)(\d*)/
I have 2 numbers: 53147
/(.*?)(\d+)/
I have 2 numbers: 53147
/(.*)(\d+)$/
I have 2 numbers: 53147
/(.*?)(\d+)$/
I have 2 numbers: 53147
/(.*)\b(\d+)$/
I have 2 numbers: 53147
/(.*\D)(\d+)$/
I have 2 numbers: 53147
/^\D*(?!123)/
ABC123
/^(\D*)(?=\d)(?!123)/
ABC445
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABC123
/^[W-]46]/
W46]789
-46]789
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Wall
Zebra
42
[abcd]
]abcd[
/^[W-\]46]/
W46]789
Wall
Zebra
Xylophone
42
[abcd]
]abcd[
\\backslash
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
-46]789
well
/\d\d\/\d\d\/\d\d\d\d/
01/01/2000
/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
2015-09-16 18:49:48 +02:00
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
2014-07-24 18:32:38 +02:00
/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
2015-09-16 18:49:48 +02:00
\= 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
2014-07-24 18:32:38 +02:00
/^(a){0,0}/
bcd
abc
aab
/^(a){0,1}/
bcd
abc
aab
/^(a){0,2}/
bcd
abc
aab
/^(a){0,3}/
bcd
abc
aab
aaa
/^(a){0,}/
bcd
abc
aab
aaa
aaaaaaaa
/^(a){1,1}/
abc
aab
2015-09-16 18:49:48 +02:00
\= Expect no match
bcd
2014-07-24 18:32:38 +02:00
/^(a){1,2}/
abc
aab
2015-09-16 18:49:48 +02:00
\= Expect no match
bcd
2014-07-24 18:32:38 +02:00
/^(a){1,3}/
abc
aab
aaa
2015-09-16 18:49:48 +02:00
\= Expect no match
bcd
2014-07-24 18:32:38 +02:00
/^(a){1,}/
abc
aab
aaa
aaaaaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
bcd
2014-07-24 18:32:38 +02:00
/.*\.gif/
borfle\nbib.gif\nno
/.{0,}\.gif/
borfle\nbib.gif\nno
/.*\.gif/m
borfle\nbib.gif\nno
/.*\.gif/s
borfle\nbib.gif\nno
/.*\.gif/ms
borfle\nbib.gif\nno
/.*$/
borfle\nbib.gif\nno
/.*$/m
borfle\nbib.gif\nno
/.*$/s
borfle\nbib.gif\nno
/.*$/ms
borfle\nbib.gif\nno
/.*$/
borfle\nbib.gif\nno\n
/.*$/m
borfle\nbib.gif\nno\n
/.*$/s
borfle\nbib.gif\nno\n
/.*$/ms
borfle\nbib.gif\nno\n
/(.*X|^B)/
abcde\n1234Xyz
BarFoo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde\nBar
/(.*X|^B)/m
abcde\n1234Xyz
BarFoo
abcde\nBar
/(.*X|^B)/s
abcde\n1234Xyz
BarFoo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde\nBar
/(.*X|^B)/ms
abcde\n1234Xyz
BarFoo
abcde\nBar
/(?s)(.*X|^B)/
abcde\n1234Xyz
BarFoo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde\nBar
/(?s:.*X|^B)/
abcde\n1234Xyz
BarFoo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde\nBar
/^.*B/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\nB
/(?s)^.*B/
abc\nB
/(?m)^.*B/
abc\nB
/(?ms)^.*B/
abc\nB
/(?ms)^B/
abc\nB
/(?s)B$/
B\n
/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
123456654321
/^\d\d\d\d\d\d\d\d\d\d\d\d/
123456654321
/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
123456654321
/^[abc]{12}/
abcabcabcabc
/^[a-c]{12}/
abcabcabcabc
/^(a|b|c){12}/
abcabcabcabc
/^[abcdefghijklmnopqrstuvwxy0123456789]/
n
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
z
/abcde{0,0}/
abcd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abce
/ab[cd]{0,0}e/
abe
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde
/ab(c){0,0}d/
abd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcd
/a(b*)/
a
ab
abbbb
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bbbbb
/ab\d{0}e/
abe
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab1e
/"([^\\"]+|\\.)*"/
the \"quick\" brown fox
\"the \\\"quick\\\" brown fox\"
/.*?/g,aftertext
abc
/\b/g,aftertext
abc
/\b/g,aftertext
abc
//g
abc
/<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
<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>
/a[^a]b/
acb
a\nb
/a.b/
acb
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
a\bx\n
a\nx\n
\= Expect no match
2014-07-24 18:32:38 +02:00
x\nb\n
/(A|B)*?CD/
CD
/(A|B)*CD/
CD
/(AB)*?\1/
ABABAB
/(AB)*\1/
ABABAB
/(?<!bar)foo/
foo
catfood
arfootle
rfoosh
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
barfoo
towbarfoo
/\w{3}(?<!bar)foo/
catfood
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
foo
barfoo
towbarfoo
/(?<=(foo)a)bar/
fooabar
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bar
foobbar
/\Aabc\z/m
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\n
qqq\nabc
abc\nzzz
qqq\nabc\nzzz
"(?>.*/)foo"
/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
2015-09-16 18:49:48 +02:00
\= Expect no match
/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
2014-07-24 18:32:38 +02:00
/(?>(\.\d\d[1-9]?))\d+/
1.230003938
1.875000282
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1.235
/^((?>\w+)|(?>\s+))*$/
now is the time for all good men to come to the aid of the party
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
this is not a line with only words and spaces!
/(\d+)(\w)/
12345a
12345+
/((?>\d+))(\w)/
12345a
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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)
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
/a(?-i)b/i
ab
Ab
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aB
AB
/(a (?x)b c)d e/
a bcd e
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a b cd e
abcd e
a bcde
/(a b(?x)c d (?-x)e f)/
a bcde f
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcdef
/(a(?i)b)c/
abc
aBc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abC
aBC
Abc
ABc
ABC
AbC
/a(?i:b)c/
abc
aBc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABC
abC
aBC
/a(?i:b)*c/
aBc
aBBc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aBC
aBBC
/a(?=b(?i)c)\w\wd/
abcd
abCd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aBCd
abcD
/(?s-i:more.*than).*million/i
more than million
more than MILLION
more \n than Million
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
MORE THAN MILLION
more \n than \n million
/(?:(?s-i)more.*than).*million/i
more than million
more than MILLION
more \n than Million
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
MORE THAN MILLION
more \n than \n million
/(?>a(?i)b+)+c/
abc
aBbc
aBBc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Abc
abAb
abbC
/(?=a(?i)b)\w\wc/
abc
aBc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Ab
abC
aBC
/(?<=a(?i)b)(\w\w)c/
abxxc
aBxxc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Abxxc
ABxxc
abxxC
/(?:(a)|b)(?(1)A|B)/
aA
bB
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aB
bA
/^(a)?(?(1)a|b)+$/
aa
b
bb
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyz
/^(?(?!abc)\d\d|\w{3}:)$/
abc:
12
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123
xyz
/(?(?<=foo)bar|cat)/
foobar
cat
fcat
focat
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
foocat
/(?(?<!foo)cat|bar)/
foobar
cat
fcat
focat
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
foocat
/( \( )? [^()]+ (?(1) \) |) /x
abcd
(abcd)
the quick (abcd) fox
(abcd
/( \( )? [^()]+ (?(1) \) ) /x
abcd
(abcd)
the quick (abcd) fox
(abcd
/^(?(2)a|(1)(2))+$/
12
12a
12aa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1234
/((?i)blah)\s+\1/
blah blah
BLAH BLAH
Blah Blah
blaH blaH
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
blah BLAH
Blah blah
blaH blah
/((?i)blah)\s+(?i:\1)/
blah blah
BLAH BLAH
Blah Blah
blaH blaH
blah BLAH
Blah blah
blaH blah
2018-08-04 10:20:18 +02:00
/((?i)blah)\s+(?m)A(?i:\1)/
blah ABLAH
\= Expect no match
blah aBLAH
2014-07-24 18:32:38 +02:00
/(?>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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
sep-12-98
/(?<=(foo))bar\1/
foobarfoo
foobarfootling
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
foobar
barfoo
/(?i:saturday|sunday)/
saturday
sunday
Saturday
Sunday
SATURDAY
SUNDAY
SunDay
/(a(?i)bc|BB)x/
abcx
aBCx
bbx
BBx
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcX
aBCX
bbX
BBX
/^([ab](?i)[cd]|[ef])/
ac
aC
bD
elephant
Europe
frog
France
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Africa
/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
ab
aBd
xy
xY
zebra
Zambesi
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aCD
XY
/(?<=foo\n)^bar/m
foo\nbar
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bar
baz\nbar
/(?<=(?<!foo)bar)baz/
barbaz
barbarbaz
koobarbaz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
baz
foobarbaz
2015-09-16 18:49:48 +02:00
# The cases of aaaa and aaaaaa are missed out below because Perl does things
# differently. We know that odd, and maybe incorrect, things happen with
# recursive references in Perl, as far as 5.11.3 - see some stuff in test #2.
2014-07-24 18:32:38 +02:00
/^(a\1?){4}$/
2015-09-16 18:49:48 +02:00
aaaaa
aaaaaaa
aaaaaaaaaa
\= Expect no match
2014-07-24 18:32:38 +02:00
a
aa
aaa
aaaaaaaa
aaaaaaaaa
aaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
2015-09-16 18:49:48 +02:00
aaaaaaaaaaaaaaaa
2014-07-24 18:32:38 +02:00
/^(a\1?)(a\1?)(a\2?)(a\3?)$/
aaaa
aaaaa
aaaaaa
aaaaaaa
2015-09-16 18:49:48 +02:00
aaaaaaaaaa
\= Expect no match
a
aa
aaa
2014-07-24 18:32:38 +02:00
aaaaaaaa
aaaaaaaaa
aaaaaaaaaaa
aaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaaaaaaaaaaa
aaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaa
2015-09-16 18:49:48 +02:00
# The following tests are taken from the Perl 5.005 test suite; some of them
# are compatible with 5.004, but I'd rather not have to sort them out.
2014-07-24 18:32:38 +02:00
/abc/
abc
xabcy
ababc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xbc
axc
abx
/ab*c/
abc
/ab*bc/
abc
abbc
abbbbc
/.{1}/
abbbbc
/.{3,4}/
abbbbc
/ab{0,}bc/
abbbbc
/ab+bc/
abbc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
abq
/ab{1,}bc/
/ab+bc/
abbbbc
/ab{1,}bc/
abbbbc
/ab{1,3}bc/
abbbbc
/ab{3,4}bc/
abbbbc
/ab{4,5}bc/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abq
abbbbc
/ab?bc/
abbc
abc
/ab{0,1}bc/
abc
/ab?bc/
/ab?c/
abc
/ab{0,1}c/
abc
/^abc$/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abbbbc
abcc
/^abc/
abcc
/^abc$/
/abc$/
aabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabcd
/^/
abc
/$/
abc
/a.c/
abc
axc
/a.*c/
axyzc
/a[bc]d/
abd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
axyzd
abc
/a[b-d]e/
ace
/a[b-d]/
aac
/a[-b]/
a-
/a[b-]/
a-
/a]/
a]
/a[]]b/
a]b
/a[^bc]d/
aed
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abd
abd
/a[^-b]c/
adc
/a[^]b]c/
adc
a-c
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a]c
/\ba\b/
a-
-a
-a-
/\by\b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xy
yz
xyz
/\Ba\B/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a-
-a
-a-
/\By\b/
xy
/\by\B/
yz
/\By\B/
xyz
/\w/
a
/\W/
-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
/a\sb/
a b
/a\Sb/
a-b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a b
/\d/
1
/\D/
-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1
/[\w]/
a
/[\W]/
-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
/a[\s]b/
a b
/a[\S]b/
a-b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a b
/[\d]/
1
/[\D]/
-
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
1
/ab|cd/
abc
abcd
/()ef/
def
/$b/
/a\(b/
a(b
/a\(*b/
ab
a((b
/a\\b/
a\\b
/((a))/
abc
/(a)b(c)/
abc
/a+b+c/
aabbabc
/a{1,}b{1,}c/
aabbabc
/a.+?c/
abcabc
/(a+|b)*/
ab
/(a+|b){0,}/
ab
/(a+|b)+/
ab
/(a+|b){1,}/
ab
/(a+|b)?/
ab
/(a+|b){0,1}/
ab
/[^ab]*/
cde
/abc/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b
/a*/
2015-09-16 18:49:48 +02:00
\
2014-07-24 18:32:38 +02:00
/([abc])*d/
abbbcd
/([abc])*bcd/
abcd
/a|b|c|d|e/
e
/(a|b|c|d|e)f/
ef
/abcd*efg/
abcdefg
/ab*/
xabyabbbz
xayabbbz
/(ab|cd)e/
abcde
/[abhgefdc]ij/
hij
/^(ab|cd)e/
/(abc|)ef/
abcdef
/(a|b)c*d/
abcd
/(ab|ab*)bc/
abc
/a([bc]*)c*/
abc
/a([bc]*)(c*d)/
abcd
/a([bc]+)(c*d)/
abcd
/a([bc]*)(c+d)/
abcd
/a[bcd]*dcdcde/
adcdcde
/a[bcd]+dcdcde/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcde
adcdcde
/(ab|a)b*c/
abc
/((a)(b)c)(d)/
abcd
/[a-zA-Z_][a-zA-Z0-9_]*/
alpha
/^a(bc+|b[eh])g|.h$/
abh
/(bc+d$|ef*g.|h?i(j|k))/
effgz
ij
reffgz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
effg
bcdd
/((((((((((a))))))))))/
a
/((((((((((a))))))))))\10/
aa
/(((((((((a)))))))))/
a
/multiple words of text/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aa
uh-uh
/multiple words/
multiple words, yeah
/(.*)c(.*)/
abcde
/\((.*), (.*)\)/
(a, b)
/[k]/
/abcd/
abcd
/a(bc)d/
abcd
/a[-]?c/
ac
/(abc)\1/
abcabc
/([a-c]*)\1/
abcabc
/(a)|\1/
a
ab
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
x
/(([a-c])b*?\2)*/
ababbbcbc
/(([a-c])b*?\2){3}/
ababbbcbc
/((\3|b)\2(a)x)+/
aaaxabaxbaaxbbax
/((\3|b)\2(a)){2,}/
bbaababbabaaaaabbaaaabba
/abc/i
ABC
XABCY
ABABC
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaxabxbaxbbx
XBC
AXC
ABX
/ab*c/i
ABC
/ab*bc/i
ABC
ABBC
/ab*?bc/i
ABBBBC
/ab{0,}?bc/i
ABBBBC
/ab+?bc/i
ABBC
/ab+bc/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABC
ABQ
/ab{1,}bc/i
/ab+bc/i
ABBBBC
/ab{1,}?bc/i
ABBBBC
/ab{1,3}?bc/i
ABBBBC
/ab{3,4}?bc/i
ABBBBC
/ab{4,5}?bc/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABQ
ABBBBC
/ab??bc/i
ABBC
ABC
/ab{0,1}?bc/i
ABC
/ab??bc/i
/ab??c/i
ABC
/ab{0,1}?c/i
ABC
/^abc$/i
ABC
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABBBBC
ABCC
/^abc/i
ABCC
/^abc$/i
/abc$/i
AABC
/^/i
ABC
/$/i
ABC
/a.c/i
ABC
AXC
/a.*?c/i
AXYZC
/a.*c/i
AABC
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AXYZD
/a[bc]d/i
ABD
/a[b-d]e/i
ACE
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABC
ABD
/a[b-d]/i
AAC
/a[-b]/i
A-
/a[b-]/i
A-
/a]/i
A]
/a[]]b/i
A]B
/a[^bc]d/i
AED
/a[^-b]c/i
ADC
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABD
A-C
/a[^]b]c/i
ADC
/ab|cd/i
ABC
ABCD
/()ef/i
DEF
/$b/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
A]C
B
/a\(b/i
A(B
/a\(*b/i
AB
A((B
/a\\b/i
A\\b
a\\B
/((a))/i
ABC
/(a)b(c)/i
ABC
/a+b+c/i
AABBABC
/a{1,}b{1,}c/i
AABBABC
/a.+?c/i
ABCABC
/a.*?c/i
ABCABC
/a.{0,5}?c/i
ABCABC
/(a+|b)*/i
AB
/(a+|b){0,}/i
AB
/(a+|b)+/i
AB
/(a+|b){1,}/i
AB
/(a+|b)?/i
AB
/(a+|b){0,1}/i
AB
/(a+|b){0,1}?/i
AB
/[^ab]*/i
CDE
/([abc])*d/i
ABBBCD
/([abc])*bcd/i
ABCD
/a|b|c|d|e/i
E
/(a|b|c|d|e)f/i
EF
/abcd*efg/i
ABCDEFG
/ab*/i
XABYABBBZ
XAYABBBZ
/(ab|cd)e/i
ABCDE
/[abhgefdc]ij/i
HIJ
/^(ab|cd)e/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABCDE
/(abc|)ef/i
ABCDEF
/(a|b)c*d/i
ABCD
/(ab|ab*)bc/i
ABC
/a([bc]*)c*/i
ABC
/a([bc]*)(c*d)/i
ABCD
/a([bc]+)(c*d)/i
ABCD
/a([bc]*)(c+d)/i
ABCD
/a[bcd]*dcdcde/i
ADCDCDE
/a[bcd]+dcdcde/i
/(ab|a)b*c/i
ABC
/((a)(b)c)(d)/i
ABCD
/[a-zA-Z_][a-zA-Z0-9_]*/i
ALPHA
/^a(bc+|b[eh])g|.h$/i
ABH
/(bc+d$|ef*g.|h?i(j|k))/i
EFFGZ
IJ
REFFGZ
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ADCDCDE
EFFG
BCDD
/((((((((((a))))))))))/i
A
/((((((((((a))))))))))\10/i
AA
/(((((((((a)))))))))/i
A
/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
A
/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
C
/multiple words of text/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AA
UH-UH
/multiple words/i
MULTIPLE WORDS, YEAH
/(.*)c(.*)/i
ABCDE
/\((.*), (.*)\)/i
(A, B)
/[k]/i
/abcd/i
ABCD
/a(bc)d/i
ABCD
/a[-]?c/i
AC
/(abc)\1/i
ABCABC
/([a-c]*)\1/i
ABCABC
/a(?!b)./
abad
/a(?=d)./
abad
/a(?=c|d)./
abad
/a(?:b|c|d)(.)/
ace
/a(?:b|c|d)*(.)/
ace
/a(?:b|c|d)+?(.)/
ace
acdbcdbe
/a(?:b|c|d)+(.)/
acdbcdbe
/a(?:b|c|d){2}(.)/
acdbcdbe
/a(?:b|c|d){4,5}(.)/
acdbcdbe
/a(?:b|c|d){4,5}?(.)/
acdbcdbe
/((foo)|(bar))*/
foobar
/a(?:b|c|d){6,7}(.)/
acdbcdbe
/a(?:b|c|d){6,7}?(.)/
acdbcdbe
/a(?:b|c|d){5,6}(.)/
acdbcdbe
/a(?:b|c|d){5,6}?(.)/
acdbcdbe
/a(?:b|c|d){5,7}(.)/
acdbcdbe
/a(?:b|c|d){5,7}?(.)/
acdbcdbe
/a(?:b|(c|e){1,2}?|d)+?(.)/
ace
/^(.+)?B/
AB
/^([^a-z])|(\^)$/
.
/^[<>]&/
<&OUT
/^(a\1?){4}$/
aaaaaaaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AB
aaaaaaaaa
aaaaaaaaaaa
/^(a(?(1)\1)){4}$/
aaaaaaaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaaaaa
aaaaaaaaaaa
/(?:(f)(o)(o)|(b)(a)(r))*/
foobar
/(?<=a)b/
ab
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
cb
b
/(?<!c)b/
ab
b
b
/(?:..)*a/
aba
/(?:..)*?a/
aba
/^(?:b|a(?=(.)))*\1/
abc
/^(){3,5}/
abc
/^(a+)*ax/
aax
/^((a|b)+)*ax/
aax
/^((a|bc)+)*ax/
aax
/(a|x)*ab/
cab
/(a)*ab/
cab
/(?:(?i)a)b/
ab
/((?i)a)b/
ab
/(?:(?i)a)b/
Ab
/((?i)a)b/
Ab
/(?:(?i)a)b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
cb
aB
/((?i)a)b/
/(?i:a)b/
ab
/((?i:a))b/
ab
/(?i:a)b/
Ab
/((?i:a))b/
Ab
/(?i:a)b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aB
aB
/((?i:a))b/
/(?:(?-i)a)b/i
ab
/((?-i)a)b/i
ab
/(?:(?-i)a)b/i
aB
/((?-i)a)b/i
aB
/(?:(?-i)a)b/i
aB
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Ab
AB
/(?-i:a)b/i
ab
/((?-i:a))b/i
ab
/(?-i:a)b/i
aB
/((?-i:a))b/i
aB
/(?-i:a)b/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AB
Ab
/((?-i:a))b/i
/(?-i:a)b/i
aB
/((?-i:a))b/i
aB
/(?-i:a)b/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Ab
AB
/((?-i:a))b/i
/((?-i:a.))b/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AB
a\nB
/((?s-i:a.))b/i
a\nB
/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
cabbbb
/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
/(ab)\d\1/i
Ab4ab
ab4Ab
/foo\w*\d{4}baz/
foobar1234baz
/x(~~)*(?:(?:F)?)?/
x~~
/^a(?#xxx){3}c/
aaac
/^a (?#xxx) (?#yyy) {3}c/x
aaac
/(?<![cd])b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
B\nB
dbcb
/(?<![cd])[ab]/
dbaacb
/(?<!(c|d))b/
/(?<!(c|d))[ab]/
dbaacb
/(?<!cd)[ab]/
cdaccb
/^(?:a?b?)*$/
\
a
ab
aaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
dbcb
a--
aa--
/((?s)^a(.))((?m)^b$)/
a\nb\nc\n
/((?m)^b$)/
a\nb\nc\n
/(?m)^b/
a\nb\n
/(?m)^(b)/
a\nb\n
/((?m)^b)/
a\nb\n
/\n((?m)^b)/
a\nb\n
/((?s).)c(?!.)/
a\nb\nc\n
a\nb\nc\n
/((?s)b.)c(?!.)/
a\nb\nc\n
a\nb\nc\n
/^b/
/()^b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a\nb\nc\n
a\nb\nc\n
/((?m)^b)/
a\nb\nc\n
/(x)?(?(1)a|b)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
a
/(x)?(?(1)b|a)/
a
/()?(?(1)b|a)/
a
/()(?(1)b|a)/
/()?(?(1)a|b)/
a
/^(\()?blah(?(1)(\)))$/
(blah)
blah
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
blah)
(blah
/^(\(+)?blah(?(1)(\)))$/
(blah)
blah
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
blah)
(blah
/(?(?!a)a|b)/
/(?(?!a)b|a)/
a
/(?(?=a)b|a)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
a
/(?(?=a)a|b)/
a
/(?=(a+?))(\1ab)/
aaab
/^(?=(a+?))\1ab/
/(\w+:)+/
one:
/$(?<=^(a))/
a
/(?=(a+?))(\1ab)/
aaab
/^(?=(a+?))\1ab/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaab
aaab
/([\w:]+::)?(\w+)$/
abcd
xy:z:::abcd
/^[^bcd]*(c+)/
aexycd
/(a*)b+/
caab
/([\w:]+::)?(\w+)$/
abcd
xy:z:::abcd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcd:
abcd:
/^[^bcd]*(c+)/
aexycd
/(>a+)ab/
/(?>a+)b/
aaab
/([[:]+)/
a:[b]:
/([[=]+)/
a=[b]=
/([[.]+)/
a.[b].
/((?>a+)b)/
aaab
/(?>(a+))b/
aaab
/((?>[^()]+)|\([^()]*\))+/
((abc(ade)ufh()()x
/a\Z/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
\
.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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
word cat dog elephant mussel cow horse canary baboon snake shark
/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123abcfoo
/(?<=(?!...999)\d{3})foo/
999foo
123999foo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123abcfoo
/(?<=\d{3}(?!999)...)foo/
123abcfoo
123456foo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123999foo
/(?<=\d{3}...)(?<!999)foo/
123abcfoo
123456foo
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123999foo
/<a[\s]+href[\s]*=[\s]* # find <a href=
([\"\'])? # find single or double quote
(?(1) (.*?)\1 | ([^\s]+)) # if quote found, match up to next matching
# quote, otherwise match up to next space
/isx
<a href=abcd xyz
<a href=\"abcd xyz pqr\" cats
<a href=\'abcd xyz pqr\' cats
/<a\s+href\s*=\s* # find <a href=
(["'])? # find single or double quote
(?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
# quote, otherwise match up to next space
/isx
<a href=abcd xyz
<a href=\"abcd xyz pqr\" cats
<a href = \'abcd xyz pqr\' cats
/<a\s+href(?>\s*)=(?>\s*) # find <a href=
(["'])? # find single or double quote
(?(1) (.*?)\1 | (\S+)) # if quote found, match up to next matching
# quote, otherwise match up to next space
/isx
<a href=abcd xyz
<a href=\"abcd xyz pqr\" cats
<a href = \'abcd xyz pqr\' cats
/((Z)+|A)*/
ZABCDEFG
/(Z()|A)*/
ZABCDEFG
/(Z(())|A)*/
ZABCDEFG
/((?>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
2015-09-16 18:49:48 +02:00
a\nxb\n
2014-07-24 18:32:38 +02:00
/(?!^)x/m
2015-09-16 18:49:48 +02:00
\= Expect no match
a\nxb\n
2014-07-24 18:32:38 +02:00
/abc\Qabc\Eabc/
abcabcabc
/abc\Q(*+|\Eabc/
abc(*+|abc
/ abc\Q abc\Eabc/x
abc abcabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyzabc
/\Gabc./g
abc1abc2xyzabc3
/abc./g
abc1abc2xyzabc3
/a(?x: b c )d/
XabcdY
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Xa b c d Y
/((?x)x y z | a b c)/
XabcY
AxyzB
/(?i)AB(?-i)C/
XabCY
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
XabcY
/((?i)AB(?-i)C|D)E/
abCE
DE
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
]
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b
/(a+)*b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
/(?i)reg(?:ul(?:[a<> ]|ae)r|ex)/
REGular
regulaer
Regex
regul<75> r
/<2F> <> <EFBFBD> <EFBFBD> [<5B> -<2D> <> -<2D> ]+/
<20> <> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD>
/(?<=Z)X./
\x84XAZXB
/ab cd (?x) de fg/
ab cd defg
/ab cd(?x) de fg/
ab cddefg
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcddefg
/(?<![^f]oo)(bar)/
foobarX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
boobarX
/(?<![^f])X/
offX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
onyX
/(?<=[^f])X/
onyX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
offX
/^/gm
a\nb\nc\n
\
/(?<=C\n)^/gm
A\nC\nC\n
/(?:(?(1)a|b)(X))+/
bXaX
/(?:(?(1)\1a|b)(X|Y))+/
bXXaYYaY
bXYaXXaX
/()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
bXXaYYaY
/[[,abc,]+]/
abc]
a,b]
[a,b,c]
/(?-x: )/x
A\x20B
"(?x)(?-x: \s*#\s*)"
A # B
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
#
"(?x-is)(?:(?-ixs) \s*#\s*) include"
A #include
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
A#include
A #Include
/a*b*\w/
aaabbbb
aaaa
a
/a*b?\w/
aaabbbb
aaaa
a
/a*b{0,4}\w/
aaabbbb
aaaa
a
/a*b{0,}\w/
aaabbbb
aaaa
a
/a*\d*\w/
0a
a
/a*b *\w/x
a
/a*b#comment
*\w/x
a
/a* b *\w/x
a
/^\w+=.*(\\\n.*)*/
abc=xyz\\\npqr
/(?=(\w+))\1:/
abcd:
/^(?=(\w+))\1:/
abcd:
/^\Eabc/
abc
/^[\Eabc]/
a
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
E
/^[a-\Ec]/
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
-
E
/^[a\E\E-\Ec]/
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
-
E
/^[\E\Qa\E-\Qz\E]+/
b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
-
/^[a\Q]bc\E]/
a
]
c
/^[a-\Q\E]/
a
-
/^(a()*)*/
aaaa
/^(?:a(?:(?:))*)*/
aaaa
/^(a()+)+/
aaaa
/^(?:a(?:(?:))+)+/
aaaa
/(a){0,3}(?(1)b|(c|))*D/
abbD
ccccD
D
/(a|)*\d/
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
2015-09-16 18:49:48 +02:00
\= Expect no match
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2014-07-24 18:32:38 +02:00
/(?>a|)*\d/
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
2015-09-16 18:49:48 +02:00
\= Expect no match
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2014-07-24 18:32:38 +02:00
/(?:a|)*\d/
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
2015-09-16 18:49:48 +02:00
\= Expect no match
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2014-07-24 18:32:38 +02:00
/\Z/g
abc\n
/^(?s)(?>.*)(?<!\n)/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\n
/^(?![^\n]*\n\z)/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\n
/\z(?<!\n)/
abc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc\n
/(.*(.)?)*/
abcd
/( (A | (?(1)0|) )* )/x
abcd
/( ( (?(1)0|) )* )/x
abcd
/( (?(1)0|)* )/x
abcd
/[[:abcd:xyz]]/
a]
:]
/[abc[:x\]pqr]/
a
[
:
]
p
/.*[op][xyz]/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
fooabcfoo
/(?(?=.*b)b|^)/
adc
abc
/(?(?=^.*b)b|^)/
adc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/(?(?=.*b)b|^)*/
adc
abc
/(?(?=.*b)b|^)+/
adc
abc
/(?(?=b).*b|^d)/
abc
/(?(?=.*b).*b|^d)/
abc
/^%((?(?=[a])[^%])|b)*%$/
%ab%
/(?i)a(?-i)b|c/
XabX
XAbX
CcC
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
XABX
/[\x00-\xff\s]+/
\x0a\x0b\x0c\x0d
/(abc)\1/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/(abc)\1/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/[^a]*/i
12abc
12ABC
/[^a]*+/i
12abc
12ABC
/[^a]*?X/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
12abc
12ABC
/[^a]+?X/i
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
12abc
12ABC
/[^a]?X/i
12aXbcX
12AXBCX
BCX
/[^a]??X/i
12aXbcX
12AXBCX
BCX
/[^a]?+X/i
12aXbcX
12AXBCX
BCX
/[^a]{2,3}/i
abcdef
ABCDEF
/[^a]{2,3}?/i
abcdef
ABCDEF
/[^a]{2,3}+/i
abcdef
ABCDEF
/((a|)+)+Z/
Z
/(a)b|(a)c/
ac
/(?>(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/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/(?>a+|ab)+c/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/(?:a+|ab)+c/
aabc
/(?(?=(a))a)/
a
/(?(?=(a))a)(b)/
ab
/^(?:a|ab)++c/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaabc
/^(?>a|ab)++c/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaabc
/^(?:a|ab)+c/
aaaabc
/(?=abc){3}abc/aftertext
abcabcabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyz
/(?=abc)+abc/aftertext
abcabcabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyz
/(?=abc)++abc/aftertext
abcabcabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyz
/(?=abc){0}xyz/
xyz
/(?=abc){1}xyz/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xyz
/(?=(a))?./
ab
bc
/(?=(a))??./
ab
bc
/^(?=(?1))?[az]([abc])d/
abd
zcdxx
/^(?!a){0}\w+/
aaaaa
/(?<=(abc))?xyz/
abcxyz
pqrxyz
/^[\g<a>]+/
ggg<<<aaa>>>
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
\\ga
/^[\ga]+/
gggagagaxyz
/^[:a[:digit:]]+/
aaaa444:::Z
/^[:a[:digit:]:b]+/
aaaa444:::bbbZ
/[:a]xxx[b:]/
:xxx:
/(?<=a{2})b/i
xaabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xabc
/(?<!a{2})b/i
xabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xaabc
/(?<=a\h)c/
xa c
/(?<=[^a]{2})b/
axxbc
aAAbc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xaabc
/(?<=[^a]{2})b/i
axxbc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aAAbc
xaabc
/(?<=a\H)c/
abc
/(?<=a\V)c/
abc
/(?<=a\v)c/
a\nc
/(?(?=c)c|d)++Y/
XcccddYX
/(?(?=c)c|d)*+Y/
XcccddYX
/^(a{2,3}){2,}+a/
aaaaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaa
aaaaaaaaa
/^(a{2,3})++a/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaa
/^(a{2,3})*+a/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaa
/\H\h\V\v/
X X\x0a
X\x09X\x0b
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
\xa0 X\x0a
/\H*\h+\V?\v{3,4}/
\x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
\x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
\x09\x20\xa0\x0a\x0b\x0c
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
\x09\x20\xa0\x0a\x0b
/\H{3,4}/
XY ABCDE
XY PQR ST
/.\h{3,4}./
XY AB PQRS
/\h*X\h?\H+Y\H?Z/
>XNNNYZ
> X NYQZ
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
>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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
defabcxyz
2015-08-03 19:25:55 +02:00
/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/
2014-07-24 18:32:38 +02:00
ababababbbabZXXXX
/(?<A>tom|bon)-\g{A}/
tom-tom
bon-bon
/(^(a|b\g{-1}))/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bacxxx
/(?|(abc)|(xyz))\1/
abcabc
xyzxyz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcxyz
xyzabc
/(?|(abc)|(xyz))(?1)/
abcabc
xyzabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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<abc>{2}/
a:aaxyz
ab:ababxyz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a:axyz
ab:abxyz
/(?'abc'\w+):\g{abc}{2}/
a:aaxyz
ab:ababxyz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a:axyz
ab:abxyz
/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
abd
ce
/^(a.)\g-1Z/
aXaXZ
/^(a.)\g{-1}Z/
aXaXZ
/^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /x
abcd
/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
(?(DEFINE)
(?<NAME_PAT>[a-z]+)
(?<ADDRESS_PAT>\d+)
)/x
metcalfe 33
/(?(DEFINE)(?<byte>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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
10.6
455.3.4.5
/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
10.6
455.3.4.5
/^(\w++|\s++)*$/
now is the time for all good men to come to the aid of the party
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
this is not a line with only words and spaces!
/(\d++)(\w)/
12345a
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
12345+
/a++b/
aaab
/(a++b)/
aaab
/(a++)b/
aaab
/([^()]++|\([^()]*\))+/
((abc(ade)ufh()()x
/\(([^()]++|\([^()]+\))+\)/
(abc)
(abc(def)xyz)
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
/^([^()]|\((?1)*\))*$/
abc
a(b)c
a(b(c))d
2015-09-16 18:49:48 +02:00
\= Expect no match)
2014-07-24 18:32:38 +02:00
a(b(c)d
/^>abc>([^()]|\((?1)*\))*<xyz<$/
>abc>123<xyz<
>abc>1(2)3<xyz<
>abc>(1(2)3)<xyz<
/^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
1221
Satanoscillatemymetallicsonatas
AmanaplanacanalPanama
AblewasIereIsawElba
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Thequickbrownfox
/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
12
(((2+2)*-3)-7)
-12
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
((2+2)*-3)-7)
/^(x(y|(?1){2})z)/
xyz
xxyzxyzz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xxyzz
xxyzxyzxyzz
/((< (?: (?(R) \d++ | [^<>]*+) | (?2)) * >))/x
<>
<abcd>
<abc <123> hij>
<abc <def> hij>
<abc<>def>
<abc<>
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
<abc
/^a+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaa
/a+b?c+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaabccc
/a+b?(*PRUNE)c+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaabccc
/a+b?(*COMMIT)c+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaabccc
/a+b?(*SKIP)c+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaabcccaaabccc
/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
aaaxxxxxx
aaa++++++
bbbxxxxx
bbb+++++
cccxxxx
ccc++++
dddddddd
/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
aaaxxxxxx
aaa++++++
bbbxxxxx
bbb+++++
cccxxxx
ccc++++
dddddddd
/a+b?(*THEN)c+(*FAIL)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaabccc
/(A (A|B(*ACCEPT)|C) D)(E)/x
AB
ABX
AADE
ACDE
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AD
/^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
1221
Satan, oscillate my metallic sonatas!
A man, a plan, a canal: Panama!
Able was I ere I saw Elba.
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
The quick brown fox
/^((.)(?1)\2|.)$/
a
aba
aabaa
abcdcba
pqaabaaqp
ablewasiereisawelba
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
rhubarb
the quick brown fox
/(a)(?<=b(?1))/
baz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
caz
/(?<=b(?1))(a)/
zbaaz
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/(?<X>a)(?<=b(?&X))/
baz
/^(?|(abc)|(def))\1/
abcabc
defdef
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcdef
defabc
/^(?|(abc)|(def))(?1)/
abcabc
defabc
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
defdef
abcdef
/(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames
a\"aaaaa
b\"aaaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
b\"11111
/(?:(?1)|B)(A(*F)|C)/
ABCD
CCD
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
CAD
/^(?:(?1)|B)(A(*F)|C)/
CCD
BCD
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ABCD
CAD
BAD
/(?:(?1)|B)(A(*ACCEPT)XX|C)D/
AAD
ACD
BAD
BCD
BAX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ACX
ABC
/(?(DEFINE)(A))B(?1)C/
BAC
/(?(DEFINE)((A)\2))B(?1)C/
BAAC
/(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
(ab(cd)ef)
/^(?=a(*SKIP)b|ac)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ac
/^(?=a(*PRUNE)b)/
ab
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ac
/^(?=a(*ACCEPT)b)/
ac
/(?>a\Kb)/
ab
/((?>a\Kb))/
ab
/(a\Kb)/
ab
/^a\Kcz|ac/
ac
/(?>a\Kbz|ab)/
ab
/^(?&t)(?(DEFINE)(?<t>a\Kb))$/
ab
/^([^()]|\((?1)*\))*$/
a(b)c
a(b(c)d)e
/(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
0
00
0000
/(?P<L1>(?P<L2>0)|(?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)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ACABX
# Check the use of names for failure
/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AC
CB
/(*MARK:A)(*SKIP:B)(C|X)/mark
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
/^(A(*THEN:A)B|C(*THEN:B)D)/mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
CB
/^(?:A(*THEN:A)B|C(*THEN:B)D)/mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
CB
/^(?>A(*THEN:A)B|C(*THEN:B)D)/mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
DEFGABC
# COMMIT inside an atomic group can't stop backtracking over the group.
/(\w+)(?>b(*COMMIT))\w{2}/
abbb
/(\w+)b(*COMMIT)\w{2}/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abbb
# Check opening parens in comment when seeking forward reference.
/(?&t)(?#()(?(DEFINE)(?<t>a))/
bac
# COMMIT should override THEN.
/(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
yes
/(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
yes
/b?(*SKIP)c/
bc
abc
/(*SKIP)bc/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
/(*SKIP)b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
/(?P<abn>(?P=abn)xxx|)+/
xxx
/(?i:([^b]))(?1)/
aa
aA
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab
aB
Ba
ba
/^(?&t)*+(?(DEFINE)(?<t>a))\w$/
aaaaaaX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaaaa
/^(?&t)*(?(DEFINE)(?<t>a))\w$/
aaaaaaX
aaaaaa
/^(a)*+(\w)/
aaaaX
YZ
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaa
/^(?:a)*+(\w)/
aaaaX
YZ
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaa
/^(a)++(\w)/
aaaaX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaa
YZ
/^(?:a)++(\w)/
aaaaX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaaa
YZ
/^(a)?+(\w)/
aaaaX
YZ
/^(?:a)?+(\w)/
aaaaX
YZ
/^(a){2,}+(\w)/
aaaaX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
YZ
/^(?:a){2,}+(\w)/
aaaaX
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
YZ
/(a|)*(?1)b/
b
ab
aab
/(a)++(?1)b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ab
aab
/(a)*+(?1)b/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2014-08-08 17:36:18 +02:00
/((?(R)a|(?1)))*/
aaa
/((?(R)a|(?1)))+/
aaa
2014-07-24 18:32:38 +02:00
/a(*:any
name)/mark
abc
/(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
a
ba
bba
# Checking revised (*THEN) handling.
# Capture
/^.*? (a(*THEN)b) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/^.*? (a(*THEN)b|(*F)) c/x
aabc
/^.*? ( (a(*THEN)b) | (*F) ) c/x
aabc
/^.*? ( (a(*THEN)b) ) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
# Non-capture
/^.*? (?:a(*THEN)b) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/^.*? (?:a(*THEN)b|(*F)) c/x
aabc
/^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
aabc
/^.*? (?: (?:a(*THEN)b) ) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
# Atomic
/^.*? (?>a(*THEN)b) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/^.*? (?>a(*THEN)b|(*F)) c/x
aabc
/^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
aabc
/^.*? (?> (?>a(*THEN)b) ) c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
# Possessive capture
/^.*? (a(*THEN)b)++ c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/^.*? (a(*THEN)b|(*F))++ c/x
aabc
/^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
aabc
/^.*? ( (a(*THEN)b)++ )++ c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
# Possessive non-capture
/^.*? (?:a(*THEN)b)++ c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
/^.*? (?:a(*THEN)b|(*F))++ c/x
aabc
/^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
aabc
/^.*? (?: (?:a(*THEN)b)++ )++ c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aabc
# Condition assertion
/^(?(?=a(*THEN)b)ab|ac)/
ac
# Condition
/^.*?(?(?=a)a|b(*THEN)c)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ba
/^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
ba
/^.*?(?(?=a)a(*THEN)b|c)/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
xacd
/(?<!a(*FAIL)b)c/
xcd
acd
/(?<=a(*:N)b)c/mark
xabcd
/(?<=a(*PRUNE)b)c/
xabcd
/(?<=a(*SKIP)b)c/
xabcd
/(?<=a(*THEN)b)c/
xabcd
/(a)(?2){2}(.)/
abcd
/(*MARK:A)(*PRUNE:B)(C|X)/mark
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
/(*MARK:A)(*PRUNE:B)(C|X)/mark
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
/(*MARK:A)(*THEN:B)(C|X)/mark
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
/(*MARK:A)(*THEN:B)(C|X)/mark,no_start_optimize
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
/(*MARK:A)(*THEN:B)(C|X)/mark
C
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
D
# This should fail, as the skip causes a bump to offset 3 (the skip).
/A(*MARK:A)A+(*SKIP)(B|Z) | AC/x,mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AAAC
# Same
/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/x,mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AAAC
/A(*:A)A+(*SKIP)(B|Z) | AC/x,mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AAAC
# This should fail, as a null name is the same as no name.
/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/x,mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AAAC
# A check on what happens after hitting a mark and them bumping along to
# something that does not even start. Perl reports tags after the failures
# here, though it does not when the individual letters are made into something
# more complicated.
/A(*:A)B|XX(*:B)Y/mark
AABC
XXYZ
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
XAQQ
XAQQXZZ
AXQQQ
AXXQQQ
/^(A(*THEN:A)B|C(*THEN:B)D)/mark
AB
CD
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AC
CB
/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
AB
CD
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AC
CB
# An empty name does not pass back an empty string. It is the same as if no
# name were given.
/^(A(*PRUNE:)B|C(*PRUNE:B)D)/mark
AB
CD
# PRUNE goes to next bumpalong; COMMIT does not.
/A(*PRUNE:A)B/mark
ACAB
# Mark names can be duplicated.
/A(*:A)B|X(*:A)Y/mark
AABC
XXYZ
/b(*:m)f|a(*:n)w/mark
aw
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
/b(*:m)f|aw/mark
abaw
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abc
abax
/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/x,mark
AAAC
/(?=a(*MARK:A)b)..x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(?=a(*MARK:A)b)..(*:Y)x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(?=a(*PRUNE:A)b)..x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(?=a(*PRUNE:A)b)..(*:Y)x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(?=a(*THEN:A)b)..x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(?=a(*THEN:A)b)..(*:Y)x/mark
abxy
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abpq
/(another)?(\1?)test/
hello world test
/(another)?(\1+)test/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
hello world test
/(a(*COMMIT)b){0}a(?1)|aac/
aac
/((?:a?)*)*c/
aac
/((?>a?)*)*c/
aac
/(?>.*?a)(?<=ba)/
aba
/(?:.*?a)(?<=ba)/
aba
/(?>.*?a)b/s
aab
/(?>.*?a)b/
aab
/(?>^a)b/s
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aab
/(?>.*?)(?<=(abcd)|(wxyz))/
alphabetabcd
endingwxyz
/(?>.*)(?<=(abcd)|(wxyz))/
alphabetabcd
endingwxyz
"(?>.*)foo"
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcdfooxyz
"(?>.*?)foo"
abcdfooxyz
/(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/
ac
/(?:(a(*SKIP)b)){0}(?:(?1)|ac)/
ac
/(?<=(*SKIP)ac)a/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abd
/(?=a(*COMMIT)b)abc|abd/
abc
abd
/(?>a(*COMMIT)b)c|abd/
abc
abd
/a(?=b(*COMMIT)c)[^d]|abd/
2015-09-16 18:49:48 +02:00
abc
\= Expect no match
2014-07-24 18:32:38 +02:00
abd
/a(?=bc).|abd/
abd
abc
/a(?>b(*COMMIT)c)d|abd/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abceabd
/a(?>bc)d|abd/
abceabd
/(?>a(*COMMIT)b)c|abd/
abd
/(?>a(*COMMIT)c)d|abd/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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)+$/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
a
/(?=a\Kb)ab/
ab
/(?!a\Kb)ac/
ac
/^abc(?<=b\Kc)d/
abcd
/^abc(?<!b\Kq)d/
abcd
/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AAAC
/^((abc|abcx)(*THEN)y|abcd)/
abcd
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
abcxy
/^((yes|no)(*THEN)(*F))?/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
yes
/(A (.*) C? (*THEN) | A D) (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) C? (*THEN) | A D) z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) C? (*THEN) | A D) \s* (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) C? (*THEN) | A D) \s* z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) (?:C|) (*THEN) | A D) (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) (?:C|) (*THEN) | A D) z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) C{0,6} (*THEN) | A D) (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) C{0,6} (*THEN) | A D) z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) (CE){0,6} (*THEN) | A D) (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCEBefgBhiBqz
/(A (.*) (CE){0,6} (*THEN) | A D) z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCEBefgBhiBqz
/(A (.*) (CE*){0,6} (*THEN) | A D) (*FAIL)/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(A (.*) (CE*){0,6} (*THEN) | A D) z/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
AbcdCBefgBhiBqz
/(?=a(*COMMIT)b|ac)ac|ac/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
ac
/(?=a(*COMMIT)b|(ac)) ac | (a)c/x
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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)(?<y>b))/mark
abc
/(*PRUNE:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
abc
/(*SKIP:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
abc
/(*THEN:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
abc
/^\d*\w{4}/
1234
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
123
/^[^b]*\w{4}/
aaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/^[^b]*\w{4}/i
aaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/^a*\w{4}/
aaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/^a*\w{4}/i
aaaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
aaa
/(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
foofoo
barbar
/(?<n>A)(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
AfooA
AbarA
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
Afoofoo
Abarbar
/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
1 IN SOA non-sp1 non-sp2(
/^ (?:(?<A>A)|(?'B'B)(?<A>A)) (?('A')x) (?(<B>)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/
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
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
/(?P<same>a)(?P<same>b)/g,dupnames
abbaba
/(?P<same>a)(?P<same>b)(?P=same)/g,dupnames
abbaba
/(?P=same)?(?P<same>a)(?P<same>b)/g,dupnames
abbaba
/(?:(?P=same)?(?:(?P<same>a)|(?P<same>b))(?P=same))+/g,dupnames
bbbaaabaabb
/(?:(?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
2015-09-16 18:49:48 +02:00
\= Expect no match
2014-07-24 18:32:38 +02:00
bbbaaaccccaaabbbcc
/(?P<Name>a)?(?P<Name2>b)?(?(<Name>)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
2014-10-10 18:16:44 +02:00
/(|ab)*?d/
abd
xyd
2014-11-05 17:05:19 +01:00
/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
1234abcd
2015-01-28 12:28:53 +01:00
/(\2|a)(\1)/
aaa
2015-02-08 18:05:12 +01:00
/(\2)(\1)/
2015-03-25 18:01:04 +01:00
"Z*(|d*){216}"
2015-03-29 13:15:32 +02:00
"(?1)(?#?'){8}(a)"
baaaaaaaaac
2015-04-23 19:28:39 +02:00
/((((((((((((x))))))))))))\12/
xx
/A[\8]B[\9]C/
A8B9C
2015-05-06 18:51:25 +02:00
/(?1)()((((((\1++))\x85)+)|))/
\x85\x85
2015-05-16 13:01:48 +02:00
"(?|(\k'Pm')|(?'Pm'))"
abcd
2015-08-03 15:18:49 +02:00
/(?|(aaa)|(b))\g{1}/
aaaaaa
bb
/(?|(aaa)|(b))(?1)/
aaaaaa
baaa
2015-09-16 18:49:48 +02:00
\= Expect no match
2015-08-03 15:18:49 +02:00
bb
/(?|(aaa)|(b))/
xaaa
xbc
/(?|(?'a'aaa)|(?'a'b))\k'a'/
aaaaaa
bb
/(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/dupnames
aaaccccaaa
bccccb
2016-10-02 18:01:01 +02:00
# /x does not apply to MARK labels
/x (*MARK:ab cd # comment
ef) x/x,mark
axxz
/(?<=a(B){0}c)X/
acX
/(?<DEFINE>b)(?(DEFINE)(a+))(?&DEFINE)/
bbbb
\= Expect no match
baaab
2016-10-18 13:22:40 +02:00
/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])/
\ Fred:099
/(?=.*X)X$/
\ X
2016-11-01 16:58:28 +01:00
/(?s)(?=.*?)b/
aabc
2016-12-10 15:59:24 +01:00
/(Z)(a)\2{1,2}?(?-i)\1X/i
ZaAAZX
2016-12-21 18:09:11 +01:00
/(?'c')XX(?'YYYYYYYYYYYYYYYYYYYYYYYCl')/
2017-01-11 17:40:35 +01:00
/[s[:digit:]\E-H]+/
s09-H
/[s[:digit:]\Q\E-H]+/
s09-H
2017-02-08 18:03:30 +01:00
/a+(?:|b)a/
aaaa
/X?(R||){3335}/
2017-03-09 17:23:28 +01:00
/(?1)(A(*COMMIT)|B)D/
ABD
XABD
BAD
ABXABD
\= Expect no match
ABX
/(?(DEFINE)(?<m> 1? (?=(?<cond>2)?) 1 2 (?('cond')|3)))
\A
()
(?&m)
\Z/x
123
/^(?:
(?: A| (1? (?=(?<cond>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
2017-03-24 19:40:15 +01:00
/^(.|(.)(?1)\2)$/
a
aba
abcba
ababa
abcdcba
/^((.)(?1)\2|.?)$/
a
aba
abba
abcba
ababa
abccba
abcdcba
abcddcba
/^(.)(\1|a(?2))/
bab
/^(.|(.)(?1)?\2)$/
abcba
2017-04-03 20:02:07 +02:00
/^(?(?=(a))abc|def)/
abc
/^(?(?!(a))def|abc)/
abc
/^(?(?=(a)(*ACCEPT))abc|def)/
abc
/^(?(?!(a)(*ACCEPT))def|abc)/
abc
2017-04-16 15:03:30 +02:00
/^(?1)\d{3}(a)/
a123a
2017-04-22 16:35:14 +02:00
# 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
# <atext> 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
2017-06-12 19:48:03 +02:00
# 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.
2017-04-22 16:35:14 +02:00
# 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 <phrase> 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)
(?<addr_spec> (?&local_part) \@ (?&domain) )
(?<angle_addr> (?&CFWS)?+ < (?&addr_spec) > (?&CFWS)?+ )
2017-06-12 19:48:03 +02:00
(?<atext> [a-z\d!#\$%&'*+-\x{2f}=?^_`{|}~] )
2017-04-22 16:35:14 +02:00
(?<atom> (?&CFWS)?+ (?&atext)+ (?&CFWS)?+ )
(?<ccontent> (?&ctext) | (?"ed_pair) | (?&comment) )
(?<ctext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ ()\\] )
(?<comment> \( (?: (?&FWS)?+ (?&ccontent) )*+ (?&FWS)?+ \) )
(?<CFWS> (?: (?&FWS)?+ (?&comment) )* (?# NOT possessive)
(?: (?&FWS)?+ (?&comment) | (?&FWS) ) )
(?<dcontent> (?&dtext) | (?"ed_pair) )
(?<display_name> (?&phrase) )
(?<domain> (?&dot_atom) | (?&domain_literal) )
(?<domain_literal> (?&CFWS)?+ \[ (?: (?&FWS)?+ (?&dcontent) )* (?&FWS)?+ \]
(?&CFWS)?+ )
(?<dot_atom> (?&CFWS)?+ (?&dot_atom_text) (?&CFWS)?+ )
(?<dot_atom_text> (?&atext)++ (?: \. (?&atext)++)*+ )
(?<dtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ \[\]\\] )
(?<FWS> (?: [\t\ ]*+ \n)?+ [\t\ ]++ )
(?<local_part> (?&dot_atom) | (?"ed_string) )
(?<mailbox> (?&name_addr) | (?&addr_spec) )
(?<name_addr> (?&display_name)? (?&angle_addr) )
(?<phrase> (?&word)++ )
(?<qcontent> (?&qtext) | (?"ed_pair) )
(?<quoted_pair> " (?&text) )
(?<quoted_string> (?&CFWS)?+ " (?: (?&FWS)?+ (?&qcontent))* (?&FWS)?+ "
(?&CFWS)?+ )
(?<qtext> [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ "\\] )
(?<text> [^\r\n] )
(?<word> (?&atom) | (?"ed_string) )
) # End DEFINE
^(?&mailbox)$/
Alan Other <user\@dom.ain>
<user\@dom.ain>
user\@dom.ain
user\@[]
user\@[domain literal]
user\@[domain literal with \"[square brackets\"] inside]
\"A. Other\" <user.1234\@dom.ain> (a comment)
A. Other <user.1234\@dom.ain> (a comment)
\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
\= Expect no match
A missing angle <user\@some.where
The quick brown fox
# --------------------------------------------------------------------------
2017-06-12 19:48:03 +02:00
# This pattern uses named groups to match default PCRE2 patterns. It's another
# heavy test for named subpatterns. Once again, code slash as \x{2f} and escape
# $ even in classes so that this works with pcre2test.
/(?sx)(?(DEFINE)
(?<assertion> (?&simple_assertion) | (?&lookaround) )
(?<atomic_group> \( \? > (?®ex) \) )
(?<back_reference> \\ \d+ |
\\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) |
\\k <(?&groupname)> |
\\k '(?&groupname)' |
\\k \{ (?&groupname) \} |
\( \? P= (?&groupname) \) )
(?<branch> (?:(?&assertion) |
(?&callout) |
(?&comment) |
(?&option_setting) |
(?&qualified_item) |
(?"ed_string) |
(?"ed_string_empty) |
(?&special_escape) |
(?&verb)
)* )
(?<callout> \(\?C (?: \d+ |
(?: (?<D>["'`^%\#\$])
(?: \k'D'\k'D' | (?!\k'D') . )* \k'D' |
\{ (?: \}\} | [^}]*+ )* \} )
)? \) )
(?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )?
(?®ex) \) )
(?<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
) : \] |
(?"ed_string) |
(?"ed_string_empty) |
(?&escaped_character) |
(?&character_type) |
[^]] ) )
(?<comment> \(\?\# [^)]* \) | (?"ed_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}!"'`=_:;,%&@~]) (?®ex)
\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> \(\? (?: = | ! | <= | <! ) (?®ex) \) )
(?<non_capturing_group> \(\? [iJmnsUx-]* : (?®ex) \) )
(?<option_setting> \(\? [iJmnsUx-]* \) )
(?<qualified_item> (?:\. |
(?&lookaround) |
(?&back_reference) |
(?&character_class) |
(?&character_type) |
(?&escaped_character) |
(?&group) |
(?&subroutine_call) |
(?&literal_character) |
(?"ed_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> \( \? \| (?®ex) \) )
(?<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> [^)]+ )
) # 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/
/<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
/^(?(DEFINE) (?<A> a) (?<B> b) ) (?&A) (?&B) /
/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>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)(?<assertion> (?&simple_assertion) | (?&lookaround) )(?<atomic_group> \( \? > (?®ex) \) )(?<back_reference> \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) )(?<branch> (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?"ed_string) | (?"ed_string_empty) | (?&special_escape) | (?&verb) )* )(?<callout> \(\?C (?: \d+ | (?: (?<D>["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) )(?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?®ex) \) )(?<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 ) : \] | (?"ed_string) | (?"ed_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) )(?<comment> \(\?\# [^)]* \) | (?"ed_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}!"'`=_:;,%&@~]) (?®ex) \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> \(\? (?: = | ! | <= | <! ) (?®ex) \) )(?<non_capturing_group> \(\? [iJmnsUx-]* : (?®ex) \) )(?<option_setting> \(\? [iJmnsUx-]* \) )(?<qualified_item> (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?"ed_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> \( \? \| (?®ex) \) )(?<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)$/
\= Expect no match
/((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
/(?:(?(2y)a|b)(X))+/
/a(*MARK)b/
/a(*CR)b/
/(?P<abn>(?P=abn)(?<badstufxxx)/
# --------------------------------------------------------------------------
2017-07-25 17:27:30 +02:00
/<(?x:[a b])>/xx
< >
/<(?:[a b])>/xx
< >
/<(?xxx:[a b])>/
< >
/<(?-x:[a b])>/xx
< >
2017-07-29 17:54:04 +02:00
/[[:digit:]-]+/
12-24
2017-10-29 17:58:38 +01:00
/((?<=((*ACCEPT)) )\1?\b) /
\= Expect no match
((?<=((*ACCEPT)) )\\1?\\b)\x20
/((?<=((*ACCEPT))X)\1?Y)\1/
XYYZ
/((?<=((*ACCEPT))X)\1?Y(*ACCEPT))\1/
XYYZ
2018-01-31 18:53:56 +01:00
/(?(DEFINE)(?<optional_a>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
2018-07-02 12:54:03 +02:00
/(?<=\G.)/g,aftertext
abc
2018-07-02 13:23:45 +02:00
/(?<=(?=.)?)/
/(?<=(?=.)?+)/
/(?<=(?=.)*)/
/(?<=(?=.){4,5})/
/(?<=(?=.){4,5}x)/
2018-07-12 19:04:43 +02:00
/a(?=.(*:X))(*SKIP:X)(*F)|(.)/
abc
/a(?>(*:X))(*SKIP:X)(*F)|(.)/
abc
/a(?:(*:X))(*SKIP:X)(*F)|(.)/
abc
2018-07-21 16:34:51 +02:00
#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/
2018-07-16 17:24:32 +02:00
abc
2018-07-21 16:34:51 +02:00
/(?=a(*ACCEPT:QQ)bc)axyz/
axyz
2018-07-16 17:24:32 +02:00
2018-07-21 16:34:51 +02:00
/(?(DEFINE)(a(*ACCEPT:X)))(?1)b/
2018-07-16 17:24:32 +02:00
abc
2018-07-21 16:34:51 +02:00
/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
2018-07-16 17:24:32 +02:00
2018-07-22 17:19:43 +02:00
/(.COMMIT)(*COMMIT::::::::::interal error:::)/
2018-07-22 17:43:00 +02:00
/(*COMMIT:<3A> <> )/
/(*COMMIT:]w)/
2018-07-28 18:23:24 +02:00
/(?i)A(?^)B(?^x:C D)(?^i)e f/
aBCDE F
\= Expect no match
aBCDEF
AbCDe f
2018-08-03 11:38:36 +02:00
2018-09-24 18:23:53 +02:00
/(*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
2018-10-20 11:28:02 +02:00
/ (?<word> \w+ )* \. /xi
pokus.
/(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
pokus.
/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
pokus.
/(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
pokus.
/(?&word)* \. (?<word> \w+ )/xi
pokus.hokus
2019-06-13 18:49:40 +02:00
/a(?(?=(*:2)b).)/mark
abc
acb
/a(?(?!(*:2)b).)/mark
acb
abc
2019-06-19 18:27:50 +02:00
/(?: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
2019-06-20 18:37:30 +02:00
/(?:a|(?=b)|.)*\z/
abc
/(?:a|(?=b)|.)*/
abc
/(?<=a(*SKIP)x)|c/
abcd
/(?<=a(*SKIP)x)|d/
abcd
2019-07-16 17:06:21 +02:00
/(?<=(?=.(?<=x)))/aftertext
abx
/(?<=(?=(?<=a)))b/
ab
2019-08-26 18:28:26 +02:00
/^(?<A>a)(?(<A>)b)((?<=b).*)$/
abc
2019-12-18 17:16:12 +01:00
/^(a\1?){4}$/
aaaa
aaaaaa
/^((\1+)|\d)+133X$/
111133X
2020-01-01 13:07:02 +01:00
/^(?=.*(?=(([A-Z]).*(?(1)\1)))(?!.+\2)){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.
2020-01-05 13:32:29 +01:00
/^(?>.*?([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.
2020-01-26 16:31:27 +01:00
"(?<=X(?(DEFINE)(A)))X(*F)"
\= Expect no match
AXYZ
"(?<=X(?(DEFINE)(A)))."
AXYZ
"(?<=X(?(DEFINE)(.*))Y)."
AXYZ
"(?<=X(?(DEFINE)(Y))(?1))."
AXYZ
2020-02-24 18:29:00 +01:00
"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word"
word
2014-07-24 18:32:38 +02:00
# End of testinput1