a(?{"{"})b - c - Sequence (?{...}) not terminated or not {}-balanced
a(?{"\{"})b cabd y $& ab
a(?{"{"}})b - c - Unmatched right curly bracket
-a(?{$bl="\{"}).b caxbd y $bl {
+a(?{$::bl="\{"}).b caxbd y $::bl {
x(~~)*(?:(?:F)?)? x~~ y - -
^a(?#xxx){3}c aaac y $& aaac
'^a (?#xxx) (?#yyy) {3}c'x aaac y $& aaac
^(??{q(.+)})\x{100} \x{100}\x{100} y $& \x{100}\x{100}
^(??{q(.)})\x{100} \x{100}\x{100} y $& \x{100}\x{100}
^(??{chr 0x100})\xbb \x{100}\x{bb} y $& \x{100}\x{bb}
-\x{100}?(??{""})xxx xxx y $& xxx
^(.)(??{"(.)(.)"})(.)$ abcd y $1-$2 a-d
^(.)(??{"(bz+|.)(.)"})(.)$ abcd y $1-$2 a-d
^(.)((??{"(.)(cz+)"})|.) abcd y $1-$2 a-b
(?<n>foo|bar|baz)(?<m>[ew]+) snofooewa y $+{m} ew
(?<n>foo)|(?<n>bar)|(?<n>baz) snofooewa y $+{n} foo
(?<n>foo)(??{ $+{n} }) snofooefoofoowaa y $+{n} foo
+(?P<n>foo|bar|baz) snofooewa y $1 foo
+(?P<n>foo|bar|baz) snofooewa y $+{n} foo
+(?P<n>foo|bar|baz)(?P<m>[ew]+) snofooewa y $+{n} foo
+(?P<n>foo|bar|baz)(?P<m>[ew]+) snofooewa y $+{m} ew
+(?P<n>foo)|(?P<n>bar)|(?P<n>baz) snofooewa y $+{n} foo
+(?P<n>foo)(??{ $+{n} }) snofooefoofoowaa y $+{n} foo
+(?P<=n>foo|bar|baz) snofooewa c - Sequence (?P<=...) not recognized
+(?P<!n>foo|bar|baz) snofooewa c - Sequence (?P<!...) not recognized
+(?PX<n>foo|bar|baz) snofooewa c - Sequence (?PX<...) not recognized
/(?'n'foo|bar|baz)/ snofooewa y $1 foo
/(?'n'foo|bar|baz)/ snofooewa y $+{n} foo
/(?'n'foo|bar|baz)(?'m'[ew]+)/ snofooewa y $+{n} foo
(x|y|z[QW])*+(longish|loquatious|excessive|overblown[QW])*+ xyzQzWlongishoverblownW y $1-$2 zW-overblownW
(x|y|z[QW]){1,5}+(longish|loquatious|excessive|overblown[QW]){1,5}+ xyzQzWlongishoverblownW y $1-$2 zW-overblownW
-
a*(?!) aaaab n - -
a*(*FAIL) aaaab n - -
a*(*F) aaaab n - -
(([abc]+) \g-1)(([abc]+) \g{-1}) abc abccba cba y $2-$4 abc-cba
(a)(b)(c)\g1\g2\g3 abcabc y $1$2$3 abc
-
+# \k<n> preceded by a literal
/(?'n'foo) \k<n>/ ..foo foo.. y $1 foo
/(?'n'foo) \k<n>/ ..foo foo.. y $+{n} foo
/(?<n>foo) \k'n'/ ..foo foo.. y $1 foo
/(?<n>foo) \k'n'/ ..foo foo.. y $+{n} foo
+/(?'a1'foo) \k'a1'/ ..foo foo.. y $+{a1} foo
+/(?<a1>foo) \k<a1>/ ..foo foo.. y $+{a1} foo
+/(?'_'foo) \k'_'/ ..foo foo.. y $+{_} foo
+/(?<_>foo) \k<_>/ ..foo foo.. y $+{_} foo
+/(?'_0_'foo) \k'_0_'/ ..foo foo.. y $+{_0_} foo
+/(?<_0_>foo) \k<_0_>/ ..foo foo.. y $+{_0_} foo
+/(?'0'foo) bar/ ..foo bar.. c - Sequence (?'
+/(?<0>foo) bar/ ..foo bar.. c - Sequence (?<
+/(?'12'foo) bar/ ..foo bar.. c - Sequence (?'
+/(?<12>foo) bar/ ..foo bar.. c - Sequence (?<
+/(?'1a'foo) bar/ ..foo bar.. c - Sequence (?'
+/(?<1a>foo) bar/ ..foo bar.. c - Sequence (?<
+/(?''foo) bar/ ..foo bar.. c - Sequence (?''
+/(?<>foo) bar/ ..foo bar.. c - Sequence (?<>
+/foo \k'n'/ foo foo c - Reference to nonexistent named group
+/foo \k<n>/ foo foo c - Reference to nonexistent named group
+/foo \k'a1'/ foo foo c - Reference to nonexistent named group
+/foo \k<a1>/ foo foo c - Reference to nonexistent named group
+/foo \k'_'/ foo foo c - Reference to nonexistent named group
+/foo \k<_>/ foo foo c - Reference to nonexistent named group
+/foo \k'_0_'/ foo foo c - Reference to nonexistent named group
+/foo \k<_0_>/ foo foo c - Reference to nonexistent named group
+/foo \k'0'/ foo foo c - Sequence \\k'
+/foo \k<0>/ foo foo c - Sequence \\k<
+/foo \k'12'/ foo foo c - Sequence \\k'
+/foo \k<12>/ foo foo c - Sequence \\k<
+/foo \k'1a'/ foo foo c - Sequence \\k'
+/foo \k<1a>/ foo foo c - Sequence \\k<
+/foo \k''/ foo foo c - Sequence \\k'
+/foo \k<>/ foo foo c - Sequence \\k<
/(?<as>as) (\w+) \k<as> (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
+
+# \g{...} with a name as the argument
+/(?'n'foo) \g{n}/ ..foo foo.. y $1 foo
+/(?'n'foo) \g{n}/ ..foo foo.. y $+{n} foo
+/(?<n>foo) \g{n}/ ..foo foo.. y $1 foo
+/(?<n>foo) \g{n}/ ..foo foo.. y $+{n} foo
+/(?<as>as) (\w+) \g{as} (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
+
+# Python style named capture buffer stuff
+/(?P<n>foo)(?P=n)/ ..foofoo.. y $1 foo
+/(?P<n>foo)(?P=n)/ ..foofoo.. y $+{n} foo
+/(?:(?P<n>foo)|(?P<n>bar))(?P=n)/ ..barbar.. y $+{n} bar
+/^(?P<PAL>(?P<CHAR>.)((?P>PAL)|.?)(?P=CHAR))$/ madamimadam y $& madamimadam
+/^(?P<PAL>(?P<CHAR>.)((?P>PAL)|.?)(?P=CHAR))$/ madamiamadam n - -
+/(?P<n>foo) (?P=n)/ ..foo foo.. y $1 foo
+/(?P<n>foo) (?P=n)/ ..foo foo.. y $+{n} foo
+/(?P<as>as) (\w+) (?P=as) (\w+)/ as easy as pie y $1-$2-$3 as-easy-pie
+
+#check that non identifiers as names are treated as the appropriate lookaround
+(?<=bar>)foo bar>foo y $& foo
+(?<!bar>)foo bar>foo n - -
+(?<=bar>ABC)foo bar>ABCfoo y $& foo
+(?<!bar>ABC)foo bar>ABCfoo n - -
+(?<bar>)foo bar>ABCfoo y $& foo
+(?<bar>ABC)foo bar>ABCfoo y $& ABCfoo
+
+(?<=abcd(?<=(aaaabcd))) ..aaaabcd.. y $1 aaaabcd
+(?=xy(?<=(aaxy))) ..aaxy.. y $1 aaxy
+
+X(\w+)(?=\s)|X(\w+) Xab y [$1-$2] [-ab]
+
+#check that branch reset works ok.
+(?|a(.)b|d(.(o).)d|i(.)(.)j)(.) d!o!da y $1-$2-$3 !o!-o-a
+(?|a(.)b|d(.(o).)d|i(.)(.)j)(.) aabc y $1-$2-$3 a--c
+(?|a(.)b|d(.(o).)d|i(.)(.)j)(.) ixyjp y $1-$2-$3 x-y-p
+(?|(?|(a)|(b))|(?|(c)|(d))) a y $1 a
+(?|(?|(a)|(b))|(?|(c)|(d))) b y $1 b
+(?|(?|(a)|(b))|(?|(c)|(d))) c y $1 c
+(?|(?|(a)|(b))|(?|(c)|(d))) d y $1 d
+(.)(?|(.)(.)x|(.)d)(.) abcde y $1-$2-$3-$4-$5- b-c--e--
+#Bug #41492
+(?(DEFINE)(?<A>(?&B)+)(?<B>a))(?&A) a y $& a
+(?(DEFINE)(?<A>(?&B)+)(?<B>a))(?&A) aa y $& aa
+\x{100}?(??{""})xxx xxx y $& xxx
+
+foo(\R)bar foo\r\nbar y $1 \r\n
+foo(\R)bar foo\nbar y $1 \n
+foo(\R)bar foo\rbar y $1 \r
+
+foo(\R+)bar foo\r\n\x{85}\r\n\nbar y $1 \r\n\x{85}\r\n\n
+(\V+)(\R) foo\r\n\x{85}\r\n\nbar y $1-$2 foo-\r\n
+(\R+)(\V) foo\r\n\x{85}\r\n\nbar y $1-$2 \r\n\x{85}\r\n\n-b
+foo(\R)bar foo\x{85}bar y $1 \x{85}
+(\V)(\R) foo\x{85}bar y $1-$2 o-\x{85}
+(\R)(\V) foo\x{85}bar y $1-$2 \x{85}-b
+foo(\R)bar foo\r\nbar y $1 \r\n
+(\V)(\R) foo\r\nbar y $1-$2 o-\r\n
+(\R)(\V) foo\r\nbar y $1-$2 \r\n-b
+foo(\R)bar foo\r\nbar y $1 \r\n
+(\V)(\R) foo\r\nbar y $1-$2 o-\r\n
+(\R)(\V) foo\r\nbar y $1-$2 \r\n-b
+foo(\R)bar foo\rbar y $1 \r
+(\V)(\R) foo\rbar y $1-$2 o-\r
+(\R)(\V) foo\rbar y $1-$2 \r-b
+
+foo(\v+)bar foo\r\n\x{85}\r\n\nbar y $1 \r\n\x{85}\r\n\n
+(\V+)(\v) foo\r\n\x{85}\r\n\nbar y $1-$2 foo-\r
+(\v+)(\V) foo\r\n\x{85}\r\n\nbar y $1-$2 \r\n\x{85}\r\n\n-b
+foo(\v)bar foo\x{85}bar y $1 \x{85}
+(\V)(\v) foo\x{85}bar y $1-$2 o-\x{85}
+(\v)(\V) foo\x{85}bar y $1-$2 \x{85}-b
+foo(\v)bar foo\rbar y $1 \r
+(\V)(\v) foo\rbar y $1-$2 o-\r
+(\v)(\V) foo\rbar y $1-$2 \r-b
+
+
+foo(\h+)bar foo\t\x{A0}bar y $1 \t\x{A0}
+(\H+)(\h) foo\t\x{A0}bar y $1-$2 foo-\t
+(\h+)(\H) foo\t\x{A0}bar y $1-$2 \t\x{A0}-b
+foo(\h)bar foo\x{A0}bar y $1 \x{A0}
+(\H)(\h) foo\x{A0}bar y $1-$2 o-\x{A0}
+(\h)(\H) foo\x{A0}bar y $1-$2 \x{A0}-b
+foo(\h)bar foo\tbar y $1 \t
+(\H)(\h) foo\tbar y $1-$2 o-\t
+(\h)(\H) foo\tbar y $1-$2 \t-b
+
+.*\z foo\n y - -